/usr/share/doc/libneedle-ruby1.8/doc/manual/parts/03_conventional.txt is in libneedle-ruby1.8 1.3.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | A conventional architecture will have each component instantiate its own dependencies. For example, the @Application@ would do something like this:
{{{lang=ruby,number=true,caption=A conventional application implementation
class Application
def initialize
@logger = Logger.new
@authenticator = Authenticator.new
@database = Database.new
@view = View.new
@session = Session.new
end
end
}}}
However, the above is already flawed, because the @Authenticator@ and the @Session@ both need access to the @Database@, so you really need to make sure you instantiate things in the right order and pass them as parameters to the constructor of each object that needs them, like so:
{{{lang=ruby,number=true,caption=A parameterized application implementation
class Application
def initialize
@view = View.new
@logger = Logger.new
@database = Database.new( @logger )
@authenticator = Authenticator.new( @logger, @database )
@session = Session.new( @logger, @database )
end
end
}}}
The problem with this is that if you later decide that @View@ needs to access the database, you need to rearrange the order of how things are instantiated in the @Application@ constructor.
|