Better Construction with Factories
نویسندگان
چکیده
class Application { List docs; protected abstract new Document(); public void newDocument() { // Handles the File|New menu option doc = new Document(); docs.add(doc); doc.open(); } // ... rest of the class omitted } (a) The abstract Application class class MyApplication extends Application { protected new Document() { return new MyDocumentType(); // A concrete subtype } // ... rest of the class omitted } (b) One possible concrete subclass Figure 7.4: Implementing pattern FACTORY METHOD with dynamically bound factories. newDocument method uses ordinary construction syntax (implemented using our notion of a factory) rather than the nonstandard “factory method” dictated by the pattern. Syntactically, the invocation of a dynamically-bound factory defined in class C for objects of class S is written as c.new S(· · · ), where c is an instance of class C. The prefix “c.” can be dropped for code inside class C (so it is replaced with this). It is not a coincidence that this looks very much like the JAVA syntax for creating an instance of a dynamic inner class: c.new I(· · · ), where c is an instance of the containing class (possibly this) and I is the inner class’s name. The constructor of a (non-static) inner class in JAVA is a method of the containing class, and not of the class it constructs— just like a client-side factory is a member of the containing class, and not of its target class. In fact, Nystrom, Chong and Myers [16] have shown that if the concept of inner classes is extended (using nested inheritance), most of the need for the FACTORY METHOD design pattern disappears. But while nested inheritance has many distinct advantages with regard to code modularity and the creation of extensible software systems, it only solves the VOL 6, NO. 6 JOURNAL OF OBJECT TECHNOLOGY 125 BETTER CONSTRUCTION WITH FACTORIES need for factory methods for classes defined inside the same module as their client. Also, it does not remove the need for instance-management patterns like INSTANCE POOL or FLYWEIGHT.
منابع مشابه
A review of Dolochar reuse methods (waste from sponge iron factories)
Background and Objective: Dolochar is the residual ash from the production of sponge iron in the process of direct reduction of iron ore by the coal-based method. In Iran, this waste is transported to the nearest landfill. However, these methods are a major environmental concern due to the fineness of the waste and the presence of heavy metals in its composition. The aim of the present study is...
متن کاملLean production, value chain and sustainability in precast concrete factory – a case study in Singapore
Research Question: Is the lean production philosophy applicable in precast concrete factories to achieve sustainability? If it is, what are the imperfections that can be improved to achieve sustainability? Purpose: This study aims to identify the contribution of the lean concept to achieve sustainability in precast concrete factories. By using appropriate lean principles, the precast concrete i...
متن کاملبررسی کیفی و مقایسه کمپوست تولیدی در کارخانه های کمپوست خمین و تهران
Backgrounds and Objectives: Over than 70% of solid wastes is consisted of food wastes with high putrecibility in Iran. Due to this regard, construction of composting factories for sanitary disposal or fertilizer production from solid wastes was very appreciated in our country. The objective of this research was to study on the quality and comparing of the compost produced by Khomain and Tehr...
متن کاملThe evolution of the Dutch dairy industry and the rise of cooperatives : a research note
Economic historians tend to explain the rise of the cooperative form in agriculture from the advantage of cooperative over private factories in reducing transaction costs with suppliers. This study provides a first test of this thesis using data on 1130 dairy factories in The Netherlands. Indeed, we find that cooperative factories performed significantly better than private factories. The persi...
متن کاملمقایسه علائم دندانی مسمومیت مزمن با فلوراید (فلوئوروزیس) درکارگران دو کارخانه صنعتی در استان مرکزی
Background: Considering the importance of examining the effects of fluorine and its compounds on aluminum industry workers, this study aimed to compare the signs of dental fluorosis between the workers of one of the aluminum factories and one of the industrial equipment construction companies of Markazi province in Iran. Methods: This descriptive study was performed on 351 workers of one of ...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید
ثبت ناماگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید
ورودعنوان ژورنال:
- Journal of Object Technology
دوره 6 شماره
صفحات -
تاریخ انتشار 2007