Generalize problem solving through design pattern

When we start solving a problem: first step to to get logic so we can program it.
Like is some where repetition which happens so we can put in loop or we can repeat data structures like stack and array.
Data Structure to generalize 
Then we take storage about which data structure to Use let us suppose we are building a program whose maximum capacity to store a number is 10^12 but we want to add
10^12 +  10 ^12 how to achieve this when max capacity is 10^12?
Then we have to use storage through data structure like Stack…
We can create 2 stacks of each number with digit arranged in LIFO.
How will we add: take simple example : we take two 3 digit numbers
123 + 456
Stack 1             Stack 2
1              |        4                                                                                                                                    2              |        5                                                                                                                                     3              |        6
————————- We can not add these no by poping() stack pointer at top
and multiplying with its position in Stack 1: Like 123= 3 X 1+2 X 10+1 X 100.
and                                                        Stack2:         456=6 X 1+ 5 X10 +6 X 100.
=——————————————————————————                      So We pop  out 1 from (Stack 1) and 6 from (Stack 2) and Add take any carry to next element of stack. We can use array we can create linked list of Equation or we can use Stack (since number are added in LIFO from left to right) Stack are best match.
As we can see How the above is added:
pop unit position from stack 1 + pop unit position from stack 2 = store in stack 3 unit position
Stack 1             Stack 2        =  StackSum
3              |        6              =      9                                                                                                            2              |        5               =      7                                                                                                        1              |        4               =     5                                                                                                            Now Stacksum will contain Numbers in sequence push(9), push(7),push(5).

But Stack pops out in LIFO so Last inserted pop(9) X 1 + pop(7) X 10 + pop(5) X 100=579.
This example used only 3 digit but actually limits of System We can Enhance using data Structure like here..
——————————————————————————————
There can be multiple practical example for menus liked through Linked List or 2 Phase commit is Oracle Using Queue of multiple user request at multiple server.  We can fit in structure based on requirement. (Lowest level of generalisation)
—————————————————————————————

More higher level (top level) from 100 feet above earth we are now coming to 1000 feet We move towards Algorithms to decide which we have used one above.. but
We analyse 2 complexity .. time complexity and space complexity suing popular BigO notation to analyse performance of Algorithm.  This performance evaluation is also generalized using BigO and using popular Algorithms..
Like we want to see segmentation of market but we do not know what are different possibility of Buckets or segments.
Then We use like popular Market Basket Algorithm….
————————————————————————————–

10,000 feet level generalisation: Design Pattern ..

In GoF (Gang of four pattern) we have There are 3 category of design pattern Behavioural, Structural and creational
more read:http://en.wikipedia.org/wiki/Design_Patterns                                                   more general read:http://en.wikipedia.org/wiki/Software_design_pattern

Example:
So We see every time we create a web site we need user login, we need to maintain session hence session level objects,
So in Design pattern We search What pattern matches this design requirements Like (Visitor pattern) fits in here.
Integration Design pattern———————————————————-
Or In general during Integration we use Bridge pattern or Adapter pattern which is used in most integration tools like Webmethods (www.webmethods.com) and TIBCO (www.tibco.com)
We have many Integration design patterns only for integration….
http://en.wikipedia.org/wiki/Enterprise_Integration_Patterns
Nowadays We have more course grain integration using Web services.
With Everything Exposed as web service is interoperable across programming languages like Java and .net and with data in XML we have data portability.
This strategy is used in like enterprise service bus or in design of many BI / BPM tools read:
https://sandyclassic.wordpress.com/2013/10/05/enterprise-service-bus-esb-bpm-orchestration-and-process-re-engineering/
————————————————————————————–
20,000 feet level generalisation: Enterprise Design pattern
Depending on requirement we will mix and match.
There are various design pattern which exist today there are thousands of algorithm which can be chosen inside each mixture of pattern chosen
Let suppose we want to mix data set of two server session user information pattern in used in Observer pattern + Merge Sort (list) and create new list.. and sink in unified database.

Read this Discussion: http://www.sitepoint.com/understanding-the-observer-pattern/

There are at Tool or development level Frameworks which exist to create already known programming structure Like Spring Framework uses Aspect Oriented Programing,
Declarative programming style is generalized with annotation @web service making a POJO exposed as Web service… Then we need to think we want restful web serices

4 Comments

  1. Pingback: My Story part-2: Harassment Of being Hindu Software Engineer | sandyclassic

  2. Pingback: Java/J2ee Security Best practices | sandyclassic

  3. Pingback: Java/J2ee Security Best practices | Java Architect's View

  4. Pingback: Java/J2EE Application Security Best practices | The Security View

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s