• Post Reply Bookmark Topic Watch Topic
  • New Topic

design Patterns  RSS feed

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi pals,


can you please tell me why do we need design patterns?


Regards,
shailaja
 
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shailaja,
Welcome to the Ranch.

Check this out
http://www.javacamp.org/designPattern/

Moving to a more appropriate forum

 
Ranch Hand
Posts: 84
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello shialaja, to explain a little about why to use design patterns i will use a metaphor or analogy, i will translate you to the building construction on an architecture point of view.

Why do everyone uses columns when building an structure?

- It's not only because it's been used since ages ago, but also because it solve, address and specific problem. There nothing better to hold and create and maintain and structure steady and it can support a lot of weigh.

Why do we use windows?

and so on,

You'll see that these things that we see on the buildings or the houses follows some patterns that solves an specific problem. When an architect sees some kind of behavior or wants to achieve something, the first thing that comes to it's mind it to look for something similar or someone that done the same before, because easier to understand and it's part of some kind of standard. If that prototype that he found solve perfectly the architect need then most of the work it's already done or if not solve the problem completely it's just only to change a few things but the main idea will be the same.

Since the beginning of software design and software development the architects have found several prototype or some desired behaviors and have seen some kind of pattern in then and they have documented the solutions that they use to solve a series of specific problems.

That why the design pattern exists and are useful for,

Regards,
 
Ranch Hand
Posts: 449
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi pals,
can you please tell me why do we need design patterns?

As Robert Martin says software design principles represent a set of guidelines that helps us to avoid having a bad design. There are 3 important characteristics of a bad design that should be avoided:

* Rigidity - It is hard to change because every change affects too many other parts of the system.
* Fragility - When you make a change, unexpected parts of the system break.
* Immobility - It is hard to reuse in another application because it cannot be disentangled from the current application.

You can use many design Principles and Patterns to avoid the above bad practices.

Open Close Principles
open for extension but closed for modifications.

Dependency Inversion Principle
* High-level modules should not depend on low-level modules. Both should depend on abstractions.
* Abstractions should not depend on details. Details should depend on abstractions.

Interface Segregation Principle
* Clients should not be forced to depend upon interfaces that they don't use.

Single Responsibility Principle
* A class should have only one reason to change.

Liskov's Substitution Principle
* Derived types must be completely substitutable for their base types.

Other then these, check out the 23 Gang of Four patterns as well.


Hope it helps.


 
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
design patterns are really an elegant, tested, and proven 'best practice' for solving a class of problems. a bunch of seasoned software developers realized they were doing some things over and over... I don't mean something like 'iterating over a collection', but something like "i need to let a bunch of objects know when this first object finishes something". There are all kinds of ways you could write that, but over time, people found what worked well and more often, what didn't.

So, they pooled their knowledge, and came up with what they thought worked the best, most of the time. These became 'design patterns'.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shialaja siddappa wrote:Hi pals,


can you please tell me why do we need design patterns?


Regards,
shailaja



Design patterns are proven (often) solutions to common problems coming up during software design. Instead of wasting a lot of time figuring out
a solution, you just use a pattern that covers solution to your problem.

Let's say you're building a software structure with user interface that contains several web-based pages. You have an element, such as text, which
you need to display in each web page. The text has to be updated for all the pages whenever its source is changed.

The first thing you can do is to come up with some solution which adds a java component for each page that periodically checks the source of the
element and when it is changed, updates it accordingly.

Another thing you can do is to look through the design patterns and see if there is something you can use, without worrying about how to design a solution.
You look through and find out that a pattern like Observer pattern can be used to solve your problem.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!