Architecture and Design Patterns
Architecture and Design Patterns
Jonathan Einav
Lecture Objectives
Open a window to the architecture and design patterns world, explain why are they needed and where did they came from, and give some examples and real world tastes of chosen DP and architectures not a programming language oriented lecture, we will mainly discuss the paradigms and uses with examples in various programming languages.
Consumer/Producer
Concurrency Pattern This design pattern coordinates the concurrent production and consumption of information among producer and consumer objects that are working on different threads. This pattern is used with some type of semaphore
Consumer/Producer - example
static AutoResetEvent eventProducerDone = new AutoResetEvent(false); static AutoResetEvent eventConsumerDone = new AutoResetEvent(false); static int currentNum = 0; static void produce(object stateInfo) { eventProducerDone.Set(); while (true) { //wait for the consumer eventConsumerDone.WaitOne(); currentNum++; eventProducerDone.Set(); } }
Consumer/Producer - example
static void Main(string[] args) { ThreadPool.QueueUserWorkItem(new WaitCallback(produce)); for (int i = 0; i < 20; i++) { eventProducerDone.WaitOne(); System.Diagnostics.Debug.WriteLine(currentNum); eventConsumerDone.Set(); } }
N tier Architecture
The n tier architecture is based on the concept of separating a system to different layers (usually 3) Each layer interacts with only the layer directly below, and has specific function that it is responsible for. Classic for IT systems
N tier Architecture
3 Tier architecture:
Presentation Layer Presentation Layer is the layer responsible for displaying user interface. Business Tier Business Tier is the layer responsible for accessing the data tier to retrieve, modify and delete data to and from the data tier and send the results to the presentation tier. This layer is also responsible for processing the data retrieved and sent to the presentation layer. BLL and DAL Often this layer is divided into two sub layers: the Business Logic Layer (BLL), and the Data Access Layers (DAL). Business Logic Layers are above Data Access Layers, meaning BLL uses DAL classes and objects. DAL is responsible for accessing data and forwarding it to BLL. Data Tier Data tier is the database or the source of the data itself.
Common mistakes tightly coupling layers in technology and writing business logic in presentation tier
Hexagon Architecture
Allow an application to equally be driven by users, programs, automated test or batch scripts.
SOA
SOA is an architectural style whose goal is to achieve loose coupling among interacting software agents. A service is a unit of work done by a service provider to achieve desired end results for a service consumer in SOA, services are the mechanism by which needs and capabilities are brought together.
SOA - Principles
Visibility the ability for a service consumer to see a service provider (Awareness, willingness and Reachability) Interaction - the activity of using a capability. (usually message exchange by contracts, constraints and policies, for example Web Service Description Language) Effect the result of an interaction
SOA - example
Component Manager drag and drop assemblies and connect functionality using events and delegate signatures, eventually compile an XML file that will represent all assemblies and connections EXE Runner Run the XML file with the EXE main thread loading the application assemblies and connecting relations in run-time
About me
B.A with honors in CS. Assumed different industrial positions such as R&D Manager, chief Architect and Projects manager in Various industry domains such as the Medical , Education and the Security domains. Consultant to various companies in software management, architecture and MS .NET issues Member of the Microsoft .NET Fight Club.