Editing
Software Design Patterns
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Modeling 'The Strategy Pattern' (Selecting behavior at runtime):''' <syntaxhighlight lang="python"> class PaymentStrategy: def pay(self, amount): pass class CreditCardPay(PaymentStrategy): def pay(self, amount): print(f"Paid ${amount} via Credit Card.") class BitcoinPay(PaymentStrategy): def pay(self, amount): print(f"Paid ${amount} via Bitcoin.") class ShoppingCart: def __init__(self, strategy): self.strategy = strategy def checkout(self, total): self.strategy.pay(total) # The user can choose the payment method at the last second: cart1 = ShoppingCart(CreditCardPay()) cart1.checkout(100) cart2 = ShoppingCart(BitcoinPay()) cart2.checkout(100) </syntaxhighlight> ; Design Landmarks : '''Design Patterns (1994)''' β The "Bible" of software engineering by Gamma, Helm, Johnson, and Vlissides, which introduced the 23 core patterns still used today. : '''Dependency Injection''' β A modern structural pattern used in almost every major framework (like Spring or Angular) to manage how objects are created and shared. : '''The 'Observer' in the Real World''' β How your phone works: When a message arrives, the "Subject" (the system) notifies all "Observers" (the screen, the vibration motor, the speaker). : '''Head First Design Patterns''' β A famous, visual book that taught an entire generation of programmers how to think in patterns rather than just syntax. </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information