Rose, Hell, Performance, Drawn

来源:互联网 发布:网站怎么优化排名靠前 编辑:程序博客网 时间:2024/05/01 06:56

            Rose, Hell, Performance, Drawn

System Architecture

·       Physical topological structure

·       Program structure

 

Subsystem Divisions

·       Subsystem overview

 

 

 

Patterns Applied in Rose

·       What are design patterns

        Please to Google .It is too difficult to give an exact and common definition.

·      Why we need patterns

      

1.     Patterns are distilled from the experiences of experts. They enable you to repeat a successful design done by someone else. By doing so you can stand on the shoulders of the experts and do not have to re-invent the wheel which means pattern provider you with a way to solve issues related to software development using a proven solution. The solution facilitates the development of highly cohesive modules with minimized coupling. They isolate the variability that may exist in system requirements and make the overall system easier to understand and maintain.

2.     For developers, design patterns are popular and effective way to think about your design. It also make communication more efficient  between  developers .software professionals can easily picture a high-level design in their heads when discussing system design

3.     Design patterns can help you think in an object-oriented way.

4.      Many projects lack basic ingredients like abstraction and separation of concerns which result in a nightmare for maintain team.

5.     Others ……

·       Patterns used in Rose Project

1.     Data Storage Samples

Get all entries by :

Context.Session.GetEntries(GetType(Department))

Context.Session.GetEntries(GetType(Tax))

                        Get specified entry by key:

                                    Context.Session.GetEntry(key,GetType(Department))

                                    Context.Session.GetEntry(key,GetType(Tax))

                        Save one entry

                                    Context.Session.Save(dep,GetType(Department))

                                    Context.Session.Save(tax,GetType(Tax))

                        Update one business entry

                                    Context.Session.Update(dep,GetType(Department))

                                    Context.Session.Update(tax,GetType(Tax))

                        Delete entry

                                    Context.Session.Delete(list,GetType(Department))

                                    Context.Session.Delete(key,GetType(Department))

                        …………………………………………….

2.     Singleton pattern and abstract factory

The class Context and Session are singleton objects. For client users, they can be accessed by a global access point. The Session object is a collection of factories .

Client working class:

                          SqlActionProvider and business entry action provider

Explanations:

            Class diagram overview:

Abstract factory (in our context, it is SqlActionProvider which is a MustInherit class) class defines the (abstract) methods (like Save, GetEntries……) for getting or creating instances of concrete classes. The client consumer calls these methods without directly knowing which concrete class is instantiated

          How can your get your concrete factory?

The secret is material’s information that refers to object type specified by client users.

3.     How session works

 

Client invokes:

Usually, the client will invoke a web method by proxy. If you like, you can wrap your proxy.

Get provider:

Find the corresponding action provider by type information in session .The session object just like a factory container which held all kinds of action providers (concrete factory).The process of finding the specified action provider is just the process of creating or getting the provider.

Execute Provider’s Routine:

Call provider’s methods to complete client request of data storage (query, save, update, delete and etc.) Client classes that call these methods should not have any direct knowledge of these concrete factory classes, but instead access singleton instances of these classes by calling a method of their abstract factory super class.

Result:

Provider’s response for data access returned by web services

Understand more:

If you read the UML diagram carefully, you will find there are some differences in our design compared to standard GOF patterns. In our abstract factory, there is not decision method like “get Factory (…)” which the client program will call to get or create a concrete factory (business entry action provider) appropriate for working with a particular product (business entry request).why? The answer is Session class. Session is a singleton manager class which is responsible for it because session shared the same interface methods or operations with abstract factory. It will decide what and when to get or create a concrete factory.

4.     Extensibility and reusability

If requirement changes force us to deal with a new business entry and corresponding data storage, we only need to two things:

1.     Define your new business entry

2.     Write your corresponding entry action provider inherited from SqlActionProvider and add it to session.

And then, you are free to access your new entry data.

         

5.     Can be improved

1.     In current rose system, many codes can be improved and enhanced. We’d better limit the Conext, Session to singleton by class design code .But unfortunately, we do not do the things like pattern requires us to do, and it still depends on class users.

2.     Configure your Business Object and the corresponding Action Provider (This point is improved in Data Transfer Services Subsystem.)

3.     Dynamic provider initialization (lazy load).

4.     Performance and Security Consideration

5.     Thread safe

6.     Object Relation Mapping

 

·      How to use design patterns

1.     Do not start immediately throwing patterns into a design, but use them as you go and understand more of the problems

2.     Write your design document by English  technical term

3.     Program based on interface

4.     Take priority to use composite instead of inherits

5.     Isolate variability

6.     Refactoring To Patterns

Performance optimization

·       refactor your code

·       optimize SQL query

·       use single loop instead of double loop if possible

·       use string builder instead of string

·       use concrete type or general type instead of object if possible

·       do not use DataRow.ItemArray to access columns

·       local data cache (or cache in memory)

·       use more efficient sort or find arithmetic

·       be careful with the method [Enum].ToString

·       use string constant to instead of object.tostring method if possible

·       use multiple thread technique properly

·       keep performance in mind while writing every line of code

Multithread programming

            In rose performance improve plan, I study .NET multithread programming thoroughly. Following sections are my experience summary

·       Basic knowledge

Thread is a lightweight process. A process can create one or more threads to execute a portion of the program code associated with the process. Use a ThreadStart delegate or the ParameterizedThreadStart delegate to specify the program code executed by a thread. The ParameterizedThreadStart delegate allows you to pass data to the thread procedure.With the help of threads we can increase the response time of application. To use multithread we have to import Threading namespace. The System. Threading namespace includes everything we need for multithread programming.

Ø     Basic Examples

Ø     Compares on background and foreground thread

Ø     Timer thread

原创粉丝点击