5

I don't want to say that is not necessary knowing design patterns. I just want to tell you my experience.

I've used Spring frameworks for four years and another frameworks (JSF, Mybatis, Hibernate, etc) in various projects where I've participated (I work as Java Developer). In all this time, I've used few design patterns. Knowing Design patterns haven't been necessary for building medium and inclusive large java web applications.

It's a few shameful saying that I only have used MVC, DAO and Factory patterns. Maybe, other two more...but I don't remember

I'm awareness that It's no good and I should improve (I'm trying to learn more about design patterns).

Firstly, I would like if someone has had the same experience that me. Secondly, if could you give information about Use of design patterns with frameworks Java (This is because is almost impossible I leave to use Java frameworks but I know I need to use design patterns for good practice).

  • 6
    The purpose of design patterns (in the GoF sense) is to overcome deficiencies in your programming language. If you can accomplish that using a framework, more power to you. – Robert Harvey Nov 2 '16 at 6:12
  • 5
    Using design patterns and knowing their names are completely different things. In fact patterns are just "common ways of programming, good or bad". So I bet you used loads of "patterns" accidentally – Richard Tingle Nov 2 '16 at 10:17
  • 1
    Spring, for one, is all about patterns, and many of the classes (eg JdbcTemplate) include the name of the pattern that they implement. Your problem, therefore, is about recognizing patterns when you use them. I suggest that you start with a single class in your application, a controller perhaps, and read through the entire GoF book until you can clearly explain why that class does or does not implement each pattern in the book. – kdgregory Nov 2 '16 at 10:57
  • Uncle Bob has an entry about it in his blog: blog.cleancoder.com/uncle-bob/2014/06/30/… – SparK Nov 29 '16 at 11:44
8

Most frameworks already use a lot of known software design patterns. So you are using design patterns unknowingly.

That said, I would strongly suggest you to try learning at least the most common ones. It's funny.

In the other hand, in a framework, your classes "fall into place" within the design of the framework, but you have to code your business logic anyways. And, in that scope, design patterns do still apply. Patterns do not only apply at an "architechtural" level but also at the level of business logic. Chances are parts of your domain classes or controlers have to solve problems that benefit from some design patterns. The so called behavioral design patterns are most likely to be used in business logic, since most frameworks already take care of the creational and structural aspects.

So the bottomline would be, no. Working mostly with frameworks doesn't mean you can no longer benefit from knowing design patterns. And, as I said before, they are fun to learn and use. To my opinion.

8

Remember, the original GoF book has the full title "Design Patterns. Elements of Reusable Object-Oriented Software.".

And most of the GoF patterns have that purpose - build software which can be put into libraries and/or frameworks and reused in a wide range of use cases, in a black-box manner, mostly following the open-closed principle.

So if one is not building any reusable software, just relying on frameworks developed by others, it is perfectly possible never to find the need to implement any of the GoF patterns by themselves. On the other hand, I am pretty sure inside any general purpose framework like Spring one can find 90% of all GoF patterns applied somewhere.

So my recommendation is - learn more about design patterns if you want to improve the design of your components to make them more reusable. If that is not what you want (which would be perfectly ok, I am not rating this), you probably do not need to learn much about those pattern.

  • So if one is not building any reusable software, just relying on frameworks developed by others, it is perfectly possible never to find the need to implement any of the GoF patterns by himself....This is my case..Then, this is not bad of all? Could I say that Spring make many developers don't use design patterns? – Cesar Miguel Nov 2 '16 at 16:29
  • 2
    @CesarMiguel: building reusable components is not an end in itself, so it is not necessarily bad. Honestly, I don't know the software you created in the past. The fact you did not miss design patterns could be either because Spring provided you with all you ever needed, or because you overlooked some opportunities to use some patterns - I cannot tell you this, and if you cannot answer that question for yourself, you need to let an experienced programmer review your code. Codereview.SE maybe an option for you. – Doc Brown Nov 2 '16 at 17:27
0

I suggest you not focus on frameworks and then focus what design patterns are. I suggest you start reading Head First Design Patterns and learn those patterns.

Then you should think about how to work with frameworks while using those patterns.

Good Luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.