What is Spring like?
-
Guys I was thinking to learn Spring but have few questions: --- is it say more difficult to learn than .NET? I am asking this because I want to evaluate: I learned C# and .NET (desktop side and BCL) very easily because of background in C. So if Spring and .NET are more or less similar in terms of programming style and complexity, I could know that I will be fine also with spring. Can you please give me some guide in this direction?
-
Guys I was thinking to learn Spring but have few questions: --- is it say more difficult to learn than .NET? I am asking this because I want to evaluate: I learned C# and .NET (desktop side and BCL) very easily because of background in C. So if Spring and .NET are more or less similar in terms of programming style and complexity, I could know that I will be fine also with spring. Can you please give me some guide in this direction?
-
Guys I was thinking to learn Spring but have few questions: --- is it say more difficult to learn than .NET? I am asking this because I want to evaluate: I learned C# and .NET (desktop side and BCL) very easily because of background in C. So if Spring and .NET are more or less similar in terms of programming style and complexity, I could know that I will be fine also with spring. Can you please give me some guide in this direction?
Basically Spring is a framework for dependency-injection which is a pattern that allows to build very decoupled systems. For example, suppose you need to list the users of the system and thus declare an interface called UserLister:
public interface UserLister {
List<User> getUsers();
}And maybe an implementation accessing a database to get all the users:
public class UserListerDB implements UserLister {
public List<User> getUsers() {
// DB access code here
}
}In your view you'll need to access an instance (just an example, remember):
public class SomeView {
private UserLister userLister;public void render() { List<User> users = userLister.getUsers(); view.render(users); }
}
Spring (Dependency Injection) approach What Spring does is to wire the classes up by using a XML file, this way all the objects are instantiated and initialized by Spring and injected in the right places (Servlets, Web Frameworks, Business classes, DAOs, etc, etc, etc...). Going back to the example in Spring we just need to have a setter for the userLister field and have an XML like this:
<bean id="userLister" class="UserListerDB" />
<bean class="SomeView">
<property name="userLister" ref="userLister" />
</bean>It is great, isn't it? :cool: