Hi there;
I hope I post this message in true place.My question is about modules in oop. In Code complete, author Mr Steve McConnell mentioned "module" in page 89.

Semantic coupling
The most insidious kind of coupling occurs when one module makes use not
of some syntactic element of another module but of some semantic knowledge of another
module's inner workings. Here are some examples:

* Module1 passes a control flag to Module2 that tells Module2 what to do. This approach
requires Module1 to make assumptions about the internal workings of Module2, namely
what Module2 is going to do with the control flag. If Module2 defines a specific data type
for the control flag (enumerated type or object), this usage is probably OK.

* Module2 uses global data after the global data has been modified by Module1. This
approach requires Module2 to assume that Module1 has modified the data in the ways
Module2 needs it to be modified, and that Module1 has been called at the right time

* Module1's interface states that its Module1.Initialize() routine should be called before its
Module1.Routine() is called. Module2 knows that Module1.Routine() calls
Module1.Initialize() anyway, so it just instantiates Module1 and calls Module1.Routine()
without calling Module1.Initialize() first.

* Module1 passes Object to Module2. Because Module1 knows that Module2 uses only
three of Object's seven methods, it initializes Object only partially—with the specific data
those three methods need.

* Module1 passes BaseObject to Module2. Because Module2 knows that Module1 is really
passing it DerivedObject, it casts BaseObject to DerivedObject and calls methods that are
specific to DerivedObject.

what does he mean by the word "module"? Can anybody describe it briefly in terms of any programming language? Thanks in advance.

Recommended Answers

All 2 Replies

It has no formal definition so its meaning is defined by the context.

Normally it just means group of related things so a module could be a group of related classes or a group of related source files, possible with-in a single process or in separate processes.

I think in your quote it problem just means "a chunk of code".

commented: for your interest +0

It seems I've missed the point in page 87. Here Mr McConnell said:

Coupling describes how tightly a class or routine is related to other classes or routines. The goal
is to create classes and routines with small, direct, visible, and flexible relations to other classes
and routines, which is known as "loose coupling." The concept of coupling applies equally to
classes and routines, so for the rest of this discussion I'll use the word "module" to refer to both
classes and routines.

I 've assumed that it is a jargon in programming languages. Thank you for your interest Banfa.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.