回復 10# xx123321


??

TOP

回復  snoopy11hk


    師兄~~唔明啊,點解有問題?(我唔熟design pattern)
請賜教!比少少keywords我去 ...
Sora 發表於 2013-5-7 00:50

你話 "因為OO 入要,係假設左所有member係應該要與世隔絕,"
與世隔絕??
咁係 factory, builder 同件 product 入面 的關係, 係所有 member 與世隔絕嗎?

TOP

回復 12# snoopy11hk

   其實我係想講 encapsulation ,當然public member係可以直接access(好似叫setter, getter?),
但基於encapsulation ,最理想唔係應該用 function/method 去access咩?
因為要能夠將每個object 當成 black box咁睇,先可以令到object之間Loosely Coupling,
用者只需知道interface( d function /method食乜出乜)就可以用,咁d code先 reusable。
factory pattern 入要都好似係用 factory method去 build product object,應該同encapsulation 唔會有矛盾。
唔好意思啊,師兄,可能係我經驗太淺,錯concept或者表達得唔好,我講member,指ge係 member field / member data。好似method 可以叫做 member function,會唔會師兄你認為我所講ge
"係假設左所有member係應該要與世隔絕",包括埋 function,所以有問題?
不過點都好,我始於唔熟design pattern,應該要再去睇多d先,希望無班門弄斧啦!
如果有錯誤,還望指正。先多謝師兄你指點。



另回 Jimmy0911,係啊,我係程序猿!

TOP

回復 11# Jimmy0911


    #13已解釋

TOP

回復  snoopy11hk

   其實我係想講 encapsulation ,當然public member係可以直接access(好似叫setter, g ...
Sora 發表於 2013-5-7 23:14



    oh, 原來你講緊 encapsulation

TOP

回復 13# Sora


    ching 寫C++定JAVA

TOP

本帖最後由 bluenemo 於 2013-5-8 01:23 編輯

object = program + data

the term "object" will have different meaning in different context. when we are talking about design, class and object are more or less refer to the same concept: some entity you can use which contains both data (attributes) and logic act upon them (methods). the concept to have some entity available in a programming language which combines data and program logic is call *encapsulation*.

when it comes to actually write the code, *class* refer to the definition of this entity. object only exists in runtime. given a class, you can have multiple copies of it running in a program. Each copy of the class created is called object. When you first create the object - what we call instantitation - system calls the *constructor* of the class - and create the object.

object (or class) can hold data (variables) with it. we can choose whether we want a particular attribute of the object to be accessible by outsiders or not - it then comes to the public or private variable (or attributes, property, different language will have different jargon to confuse people).

recall that we can have multiple copies of the class exist in the system as objects. when there are cases we want some attributes to hold one value for all the objects, we will define those attributes as *class* level attributes - every object created will have the same value.

Take note that different OOP languages will have slightly different treatment on how to invoke the constructor (chings who knows a lot details please don't challenge me, just want to give a general idea here).

The banana example quoted by the ching in #4 is about inheritance, which is another OOP concept allows class to create base on some other class.

Other concepts like factory and design patterns are more advance concepts in object-oriented design.

TOP

出現啦!!高手出現啦!!
簡潔而有力地介紹左咩係object!
bluenemo師兄,請問有無學design pattern 書好介紹?
回Jimmy0911 : 之前寫過下C#

TOP

出現啦!!高手出現啦!!
簡潔而有力地介紹左咩係object!
bluenemo師兄,請問有無學design pattern 書好介 ...
Sora 發表於 8/5/2013 08:11 PM


呢本:http://en.wikipedia.org/wiki/Design_Patterns_(book)

學Design Pattern為何唔睇四人幫呢本?

TOP

回復 18# Sora


    尼D叫Design Pattern?
inheritance 個D都係?

TOP