Skip to Content
Lean Architecture for Agile Software Development
book

Lean Architecture for Agile Software Development

by James Coplien, Gertrud Bjørnvig
August 2010
Intermediate to advanced
376 pages
10h 6m
English
Wiley
Content preview from Lean Architecture for Agile Software Development

Appendix B. Account Example in Python

"""
DCI proof of concept
Context is a separate object to the Collaboration (again for
exploration of alternatives). Made a class for it, but a
Dictionary is also possible.

Author: David Byers, Serge Beaumont
7 October 2008
"""

import new

class Role(object):
    """A Role is a special class that never gets
    instantiated directly. Instead, when the user wants
    to create a new role instance, we create a new class
    that has the role and another object's class
    as its superclasses, then create an instance of that
    class, and link the new object's dict to the original
    object's dict."""
        def __new__(cls, ob):
          members=dict(__ob__=ob)
          if hasattr(ob.__class__, '__slots__'):
           members['__setattr__']=Role.__setattr
members['__getattr__']=Role.__getattr members['__delattr__']=Role.__delattr c = new.classobj("%s as %s.%s" % (ob.__class__.__name__, cls.__module__, cls.__name__), (cls, ob.__class__), members) i = object.__new__(c) if hasattr(ob, '__dict__'): i.__dict__=ob.__dict__ return i def __init__(self, ob): """Do not call the superclass __init__. If we did, then we would call the __init__ function in the real class hierarchy too (i.e. Account, in this example)""" pass def __getattr(self, attr): """Proxy to object""" return getattr(self.__ob__, attr) def __setattr(self, attr, val): """Proxy to object""" setattr(self.__ob__, attr, val) def __delattr(self, attr): """Proxy to object""" delattr(self.__ob__, attr) class MoneySource(Role): def transfer_to(self, ctx, amount): ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Agile Software Architecture

Agile Software Architecture

Muhammad Ali Babar, Alan W. Brown, Ivan Mistrik
Lean Software Development: An Agile Toolkit

Lean Software Development: An Agile Toolkit

Mary Poppendieck, Tom Poppendieck

Publisher Resources

ISBN: 9780470684207Purchase book