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

推荐订阅源

博客园_首页
H
Help Net Security
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
A
About on SuperTechFans
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享
aimingoo的专栏
aimingoo的专栏
F
Fortinet All Blogs
博客园 - 【当耐特】
Microsoft Security Blog
Microsoft Security Blog
Martin Fowler
Martin Fowler
I
InfoQ
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
Engineering at Meta
Engineering at Meta
腾讯CDC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
U
Unit 42
The Cloudflare Blog
Y
Y Combinator 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
Facade
Yusuf Aytas · 2010-01-11 · via Yusuf Aytas

Published · 2 min read

Bu yazımda size Facade adındaki nesneye dayalı yazılım şablonunu (Object-Oriented Design Pattern) anlatacağım. Bu şablon(pattern) genelde birden fazla pakete (package) aynı anda erişip bunlarla ilgili işlemleri yapabilmek adına tasarlanmış bir dizayndır. Demek istediğim birden fazla işlevi bir arada bulunduran işlemleri temelde daha kolaya indirgeyen bir yazılım unsurudur. Buna şöyle örnek verelim. Sizin computer adında bir sınıfınız(class) var. Computer çalışması için birden fazla parça kulanır. Biz sadece CPU, Ram ve harddisk kullandığını varsayalım. Şimdi bu saydığım parçaların her biri paket olarak tasarlayalım çünkü birden fazla işlevi yerine getiriyor. Mesela CPU'yu ele alalım. Bu paketin içinde birden fazla sınıf bulunur. İşte dışarıdaki sınıfları bu kargaşadan kurtarmak için bir facade sınıfı yazarız ve bu sınıf üzerinden erişimi sağlarız. Şimdi bunu bir uml şeması ile gösterelim.

Facade tasarım deseni şemasıFacade tasarım deseni şeması

public class ALU{
	public void execute(){
		//execute instructions
	}
}
public class Latch{
	public void fetch(){
		//fetch intruction from memory
	}
}
public class Disk{
	public void data(){
		//gets data from disk
	}
}
public class Computer{
	ALU alu;Latch latch;Disk disk;
	public Computer(){
		alu = new ALU();
		latch = new Latch();
		disk = new Disk();
	}
	public void run(){
		alu.execute();
		latch.fetch();
		disk.data();
	}
}
public class User{
	public static void main(String \[\] args){
		Computer computer = new Computer();
		computer.run();
	}
}