經常有人死吹精通設計模式,確理不清什麼是設計模式。個人感覺很多東西和下棋一樣,幾分鐘學會,一輩子去精通。這裏摘取幾句,解釋一下。
類庫,框架與設計模式的適用性區分
1 libraries and frameworks go a long way towards a development model where we can just pick and choose components and plug them right in . bug .. they don't help us structure our own applications in ways that are easier to understand ,more maintainable and flexible that's where design patterns come in.
2 design patterns are higher level than libraies design patterns tell us how to structure classed and objects to solve certain problems and it is our job to adapt those designs to fit our particular application.
3 frameworks and libraries are not design paterns they provide specific implementations that we link into our code sometimes however libraries and frameworks make use of design patterns in their implementations that's great because once you understand design patterns ,you 'll quikly.understand APIs that are structured around design patterns
雜記:不要以爲了解了oo 的基礎就可以自動的building 靈活可重用,易維護的代碼.remember knowing concepts like abstraction inheritance and polymorphism do not make you a good object oriented designer.
bullet points knowing the oo basics dose not make you a good oo designer.
good oo designs are reusable ,extensible and maintainable
patterns show you how to build systems with good oodesign qualities.
patterns are proven object oriedted experience
patterns don't give you code ,they give you general solutions to design problems you apply them to your specific application.
most patterns and priciples address issues of change in software
most patterns allow some part of a system to vary independently of all other parts
we often try to take what varies in a system and encapsulate it
patterns provide a shared language that can maximize the value of you communication with other developers
雜記: 方法。
don't miss out when something interstiong happens!
we 've got a pattern that keeps your objects in the know when something the might care about happens objects can even decide at runtime whether they want to be kept informed the observer pattern is one of the most heavily use patterns in the JDK and it's incredibly useful before we're down we 'll also look at one to many relationships and loose coupling with observer you 'll be the life of the patterns party..