惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Troy Hunt's Blog
Scott Helme
Scott Helme
T
Threat Research - Cisco Blogs
T
Tenable Blog
L
LINUX DO - 热门话题
V
Visual Studio Blog
I
Intezer
Blog — PlanetScale
Blog — PlanetScale
Cisco Talos Blog
Cisco Talos Blog
A
Arctic Wolf
C
Cyber Attacks, Cyber Crime and Cyber Security
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
Know Your Adversary
Know Your Adversary
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
N
Netflix TechBlog - Medium
SecWiki News
SecWiki News
I
InfoQ
Microsoft Security Blog
Microsoft Security Blog
Project Zero
Project Zero
W
WeLiveSecurity
Microsoft Azure Blog
Microsoft Azure Blog
A
About on SuperTechFans
Recorded Future
Recorded Future
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Vercel News
Vercel News
S
Securelist
Spread Privacy
Spread Privacy
L
LangChain Blog
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
MongoDB | Blog
MongoDB | Blog
Google DeepMind News
Google DeepMind News
Recent Commits to openclaw:main
Recent Commits to openclaw:main
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
The Last Watchdog
The Last Watchdog
Attack and Defense Labs
Attack and Defense Labs
博客园 - 司徒正美
Help Net Security
Help Net Security
L
Lohrmann on Cybersecurity
人人都是产品经理
人人都是产品经理
Forbes - Security
Forbes - Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
PCI Perspectives
PCI Perspectives
博客园 - 【当耐特】
T
Tor Project blog

Yusuf Aytas

When Code Is Cheap, Does Quality Still Matter? Why Crouching Tiger, Hidden Dragon Is a Masterpiece Why We Ignore Advice The Mirror Is Part of the Machine When Too Many Maps Overlap on One Person The Work Runs on Different Maps Your Work Introduces You Trial By Fire The Dude Why Headcount Math Lies Capacity Is the Roadmap The Roadmap Is Not the System Torres del Paine W Trek Escaping Status Theater Incentives Drive Everything Scaling Culture Without Dilution What Good Looks Like Why Airport Security Feels Random Why Politics Appear How to Work with Me The Janus Protocol Multi-Horizon Delivery Framework What Good Execution Looks Like Managing Your Manager Why Kingdom of Heaven’s Director’s Cut Is Better AI Broke Interviews Most of What We Call Progress Managers Have Been Vibe Coding All Along Stop Wasting Brainpower Why Over-Engineering Happens Prisoner's Dilemma Climbing No More The Weekly Win Mevlana Candy Brewing Turkish Tea Onboarding Your Engineering Manager Technical Deep Dives Yapay Zekâ Çağında Bilgisayar Mühendisliği Building Remote Teams From Idea to Launch in 2 Weeks Reflecting on Software Engineering Handbook Representing the Business New Manager Survival Guide Take Self Reviews Seriously Chasing Real Respect The Invisible Difference Learning the Johari Window Management is a Lonely Place Simple Task Management AI Balance in Work PIP Manager Insights Engineering Manager Interview Preparation Work-Life Balance as a Manager Bridging the Management Disconnect Tech Hiring Bubble Bursts Traits for EMs Simple Acts of Recognition Matter The Question I Ask Every New Report The Reality of an Employer's Market Bridging Ideals and Reality Hiring Red Flags Why The Godfather Is So Damn Good Subteam Tenets No Fluff Please Losing a Top Performer Balancing Act of Reliability Building Trust in Engineering Teams Ideal Number of Direct Reports Overriding a People Leader’s Decision From Misperception to Promotion Perception vs Perspective Setting Goals From Engineer to Manager Getting Delegation Right Interviewing Your Future Boss Celebrating Our Book in Iceland Operational Skills Needed On Writing Software Engineering Handbook Charlie Munger Quotes Working with Dependencies From Las Vegas to Canyons Navigating Layoffs Handling Competitive Dynamics A Weekend Getaway to Malta Engineering Health Essentials Should Dev Managers Code? Confronting the Life on Pause Winning Eleven Kindness is A Choice Bireysel Katılımcılar ve Yöneticiler Leading from Where You Are The Subtle Art of Listening Coding in Leadership The Power of Consistency The Making of a Leader The Path to Leadership Embracing TikTok Talent Sourcing Journey Leading Self Managing Teams Cracking Coding Bottlenecks
Abstract Factory
Yusuf Aytas · 2010-01-10 · via Yusuf Aytas

Published · 2 min read

Bu yazımda size Abstract Factory adındaki nesneye dayalı yazılım şablonunu (Object-Oriented Design Pattern) anlatacağım. Abstract factory,  bir veya birden fazla nesnenin farklı türlerinin, ihtiyaca göre yaratılmasını amaçlayan tasarım şablonudur. Örnek vererek daha iyi açıklamak istiyorum. Bir çok farklı türde telefon mevcut ve buda hepsinin kendine has platformu olmasına neden oluyor. Dolayısıyla  telefon için bir uygulama geliştirdiğimizde, yaptığımız bir düğme(button) yada bir panel ortama göre değişmesi gerekecektir. Bu durumda düğmeleri Button, çeşitlerinide Button'dan türeyen düğmeler şeklinde tasarlarız. Aynı işlemleri paneller içinde yaparız. Oluşturacağımız AbstractFactory'den türeyen sınıfları ise platforma göre çeşitlendiririz. Eğer bizden Android buttonı isternirse, dolayısıyla Android düğmesini AndroidFactory'den yararlanarak yaratabiliriz. Aynı şekilde bunu Android Panel içinde yapabiliriz. Eğer yeni bir platform gerekirse tek yapmamız gereken onun factorisini oluşturup, ona ait button ve panelleri eklemek olacaktır. Yazdığımız diğer sınıflar aynen kalabilir.

Abstract Factory tasarım deseni şemasıAbstract Factory tasarım deseni şeması

public abstract class ProductA{}
public class ProductA1 extends ProductA{}
public class ProductA2 extends ProductA{}
public abstract class ProductB{}
public class ProductB1 extends ProductB{}
public class ProductB2 extends ProductB{}
public abstract class AbstractFactory{
	public ProductA getA();
	public ProductB getB();
}
public class Factory1{
	public ProductA getA(){
		return new ProductA1();
	}
	public ProductB getB(){
		return new ProductB1();
	}
}
public class Factory2{
	public ProductA getA(){
		return new ProductA2();
	}
	public ProductB getB(){
		return new ProductB2();
	}
}
public class User{
	public static void main(String \[\]args){
		AbstractFactory factory = new Factory1();
		factory.getA();
	}
}