| Framework can help programmers to quickly generate “code architectureâ€, then significantly improves development effectiveness. Framework is meanly uses class inheritance to achieve functional expansion, however, at the same time, structural expansion makes relationships between class and class tightly bound. This inheritance system once goes too deep, it meanwhile will bring a lot of problems. Such as, the difficulty is very high in framework design, development curve is very steep, maintenance costs are very high, etc.Paper is based on a library named “OCFâ€, OCF separates interface from implemention. In OCF, we let many small modules as a unit, and do our best to make them orthogonal each other. We separate interface and the implementions, then we may have different implementions for the same interface, which is called the “Policy†in OCF. OCF achieves that class and the framework of inheritance hierarchy decouples, with an interface to describe a functional expansion, at last it achieves a combination of orthogonal features; while using different polices in a flexible way to replace the functional requirements under different scenarios.Component technology is the way to the development of software reuse. Based on the “interface-policy†library, this paper builds a COM local environment. OCF experiments a technology building COM object and component by a combination of source-level approach. This technique is derived by means of the “Type Infer Componentâ€, and we use meta-programming to compute and deduce “typeâ€, put a number of policies in “interface-policy†library together and build a series of prerequisite components of COM, finally, we get a COM supporting environment within process with these components. COM supports functions as follows, positioning and loading of component(essentially, a component factory), automated registration of component, information management of component, etc.Under the principle of separation of interface and policy, OCF makes the framework easy to expand, and for different interface, you can have a variety of different implemention policy, which brings a lot of flexibility to the framework. This paper’s COM framework is based on OCF, it uses a combination of policies to produce components, in this way, the framework has features as open, easy to extend and cross-platform. |