- We write if-else, switch, while, AND, OR and equalsIgnoreCase more than we know. Our business logic depends on them.
- We also do some reading from / writing to a persistent store in most of our projects. We write to the files. We write to cache, in-memory or session. We write to the database. We write to a stream (byte or character). We write to the indexer (Solr, graph, nodes). And then we read from it all.
- We leverage maps and lists for the rest of the code. We store things as key value pair. We iterate over a map or list in most of our projects. We iterate over objects which come from various sources in these lists or map. We iterate over items from the persistent stores I mentioned above.
- We figure out a way to send the data that we played with in three steps above all the way up to the browser. This exchange of data is web development. Web Frameworks make this possible.
上面的4句话是赤裸裸的现实。
作为一个开发者,一个项目我觉得应该有以下几条准则需要确认:
Criteria 1: You need to build something fast.
Criteria 2: You have to learn an existing system and improve upon it.
Criteria 3: You have to integrate with an outside service provider to pull or push data.
Criteria 4: You are able to work with limited control over presentation.
Criteria 5: And you want your system to be mature and perform well.
以下是列举Spring框架的好处。
Spring Framework
With Spring, I can build something fast. Let me give you an example.
I am learning Cassandra for one of my projects. I spent couple hours learning how to setup Cassandra and understanding CQL.
I am already familiar with Spring Data for MongoDB and Oracle. Bringing Spring Data for Cassandra was as simple as pulling ‘Cassandra’ dependency Jar.
The Spring Initializer generated jar came with a unit test. I added Cassandra properties and an example I copied from the web. Voila! I am in business. Maybe I will do a video showing this next.
With Spring, I can work with an existing system and improve it.
Most of my projects involved taking an existing system and enhancing it with Spring. Spring Framework allowed me to not disrupt any existing behavior but build in parallel. I migrated to Spring in increments.
With Spring, I can integrate my application to expose to or pull from third party services.
I can give you a number of examples here.
I used to work with Axis2 and brought Spring to expose my service as SOAP.
I had an existing Spring MVC application and leveraged same service to expose as a REST resource.
Spring allows me to switch between JAX-RS Implementations.
Spring allows me to switch between databases with minimal code changes.
With Spring, I can work with any front-end technology.
I have worked with Struts, jQuery, AngularJS, Tapestry and JSF with Spring as a backbone. I worked with Handlebars, Thymeleaf, JSP, JSTL, Tiles, Free Marker, SiteMesh and Velocity templates. Speaking of AngularJS + Spring, check out jHipster.
With Spring, I get a mature framework.
This beats almost all the other criteria above. And I can say this separates Spring Framework from the rest of the offerings out there in any language.
I can bring upcoming technologies into Spring and later swap it with others if needed. Without disturbing the underlying architecture.
You could use Spring framework for web applications. You could use Spring as an MVC framework which is only one part of its offering. You could use it as a backbone for integrating all layers.
Spring provides full stack flexibility in my projects that is hard to come by in ANY language or a framework. The thriving community has a plethora of plugins to integrate with most other prominent tools.
You could take these same criteria, apply it to any language and identify winner amongst them. Remember your winner may be different than someone else’s winner for the same criteria.