java - I want to know the meaning of compile-time decisions -


what mean "with inheritance you're locked compile-time decisions code behavior".

i suggest post donal fellows on programmers,

some languages pretty static, , allow specification of inheritance relationship between 2 classes @ time of definition of classes. c++, definition time practically same compilation time. (it's different in java , c#, not much.) other languages allow more dynamic reconfiguration of relationship of classes (and class-like objects in javascript) each other; go far allowing class of existing object modified, or superclass of class changed. (this can cause total logical chaos, can model real world nasties quite well.)

but important contrast composition, relationship between 1 object , not defined class relationship (i.e., type) rather references each has in relation other. general composition powerful , ubiquitous method of arranging objects: when 1 object needs know another, has reference other object , invokes methods upon necessary. start looking super-fundamental pattern, you'll find absolutely everywhere; way avoid put in 1 object, massively dumb! (there's stricter uml composition/aggregation, that's not gof book talking there.)

one of things composition relationship particular objects not need hard-bound each other. pattern of concrete objects flexible, in static languages c++. (there upside having things static: possible analyse code more closely , — @ least potentially — issue better code less overhead.) recap, javascript, many other dynamic languages, can pretend doesn't use compilation @ all; pretence, of course, fundamental language model doesn't require transformation fixed intermediate format (e.g., “binary executable on disk”). compilation done done @ runtime, , can redone if things vary much. (the fascinating thing such job of compilation can done, starting dynamic basis…)

some gof patterns make sense in context of language things static. that's ok; means not forces affecting pattern listed. 1 of key points studying patterns helps aware of these important differences , caveats. (other patterns more universal. keep eyes open those.)

profile 74u n3u7r1no @ stack overflow, q&a professional , enthusiast programmers


Comments