473,778 Members | 1,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Smart dummy objects

I'd appreciate comments on what I'm doing.

Please be kind, I'm a new kid on the block.
Here's my application.

I'm writing some test code.

(I'm a recent convert to unit testing.)
I want to test a series of changes to an object.

The change methods return self, so I can form chains.

Like so:
x = obj.this().that (12).other(x=3, y=12)
assert x is obj
A Dummy class (easily coded) allows:
d = Dummy()
y = d.this().that(1 2).other(x=3, y=12)
assert y is d
to execute without errors.

Function calls (and getting attributes) do not change d.

And these operations return self.
I'm looking for a SmartDummy class.

So that:
sd = SmartDummy()
sd.this.that(12 ).other(x=3, y=12)
assert z is sd
always executes without errors (it's a Dummy) ...
.... and because it's a SmartDummy,
magic = sd.special_meth od_name(obj)
is equivalent to
magic = obj.this().that (12).other(x=3, y=12)
even to the raising of exceptions.
This allows a chain of changes to be stored in a SmartDummy.

And then applied to a succession of real objects.
Before writing much code, I did a google for "SmartDummy " and "smart
dummy" in this newsgroup.

I got no hits, which discouraged me.

I then searched all newsgroups. Got 24 and 39,200 hits resp.

http://groups.google.com/groups?hl=en&lr=&q=SmartDummy
http://groups.google.com/groups?hl=e...G=Search&meta=

The 24 were not helpful, the 39,200 too many.
A search of the web for SmartDummy was not helpful.
http://www.google.com/search?hl=en&lr=&q=SmartDummy
But "Smart Dummy" was.
http://www.google.com/search?q=Smart...r=&sa=N&tab=gw

The very first hit was:
http://www.tc.gc.ca/mediaroom/releas...4/04-h082e.htm

It announced the Canadian debut of:
===
WorldSID (World Side Impact Dummy) was born out of a need to have a
world harmonized crash test dummy that would better simulate the motions
of a human in side impact crash testing.
===
This encouraged me. Smart Dummies are important. They can save lives.

Maybe they are a good idea. Let's try to make a Python SmartDummy.

So I went ahead and spend the morning coding up my SmartDummy class.
Much of it is now working, but it's not yet ready for its Python debut.

Hope this of interest.
BTW, I'm a bit of a Python newbie, particularly regarding culture.

This is my first post to comp.lang.pytho n. (I was a lurker.)

However, I am a regular on comp.text.tex.
As I said, I'd appreciate your comments on this.
Jonathan

Jul 18 '05 #1
0 1304

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
3412
by: Susan Baker | last post by:
Hi, I'm just reading about smart pointers.. I have some existing C code that I would like to provide wrapper classes for. Specifically, I would like to provide wrappers for two stucts defined as ff: typedef struct { float *data ; int count ;
6
3098
by: Shankar | last post by:
Hello, We have a smart pointer class which provides the dereference operator -> to access the underlying object pointer. Now, we have a new requirement where a different type of object (e.g from memory, disk, network etc) needs to be returned by the smart pointer on access. I was thinking of using the function call operator () since that can take arguments e.g :-
16
4124
by: Yong Hu | last post by:
Does the smart pointer never lead to memory leak? Thanks,
92
5123
by: Jim Langston | last post by:
Someone made the statement in a newsgroup that most C++ programmers use smart pointers. His actual phrase was "most of us" but I really don't think that most C++ programmers use smart pointers, but I just don't know. I don't like them because I don't trust them. I use new and delete on pure pointers instead. Do you use smart pointers?
14
18210
by: Ian | last post by:
I am looking at porting code from a C++ application to C#. This requires implementing data sharing functionality similar to what is provided by a smart pointer in C++. I have only recently begun to work in C# and am asking for suggestions/comments of how to implement a similar data sharing technique in C#. A C++ smart pointer can be used to share common information. For example, assume information managed by objects I1, I2, I3,...
33
5083
by: Ney André de Mello Zunino | last post by:
Hello. I have written a simple reference-counting smart pointer class template called RefCountPtr<T>. It works in conjunction with another class, ReferenceCountable, which is responsible for the actual counting. Here is the latter's definition: // --- Begin ReferenceCountable.h ---------- class ReferenceCountable
3
2128
by: Nindi73 | last post by:
Hi, I am in need of a deep copy smart pointer (Boost doesn't provide one) which doesnt require the contained types to have a virtual copy constructor. I wrote a smart pointer class that I think meets these requirements, but after reading the chapter on exceptions in 'Exceptional C++':Sutter, I am not sure if its is really Exception safe or Exception Neutral. I suppose putting the theory in that chapter into practice isn't trivial.
11
3437
by: Nindi73 | last post by:
A few days a ago I posted my code for a deep copy pointer which doesn't require the pointee object to have a virtual copy constructor. I need help with checking that it was exception safe and exception neutral/ I got a reply from Bux with his code for a smart pointer with far fewer lines of code and more cleaner design, not over engineered like mine. ...
54
12019
by: Boris | last post by:
I had a 3 hours meeting today with some fellow programmers that are partly not convinced about using smart pointers in C++. Their main concern is a possible performance impact. I've been explaining the advantages of smart pointers endlessly (which are currently used in all our C++ software; we use the Boost smart pointers) as I'm seriously concerned that there is a shift to raw pointers. We are not developing system software but rather...
0
9465
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10296
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9923
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7474
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5497
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4031
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2863
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.