Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I have "inherited" some C++ code....

70 views
Skip to first unread message

Robert Hutchings

unread,
Sep 17, 2014, 3:00:27 PM9/17/14
to
My manager gave me this code today, and I am not sure understand the Patterns code. I know ABOUT design patterns (GoF, etc), but has anyone seen code like this before?

**********************************************************************************
Abstract Instrument class
This class is purely abstract and defines the interface of concrete instruments
which will be derived from this one. It implements the Observable interface
**********************************************************************************/
class Instrument : public Patterns::Observer, public Patterns::Observable
{
public:

Instrument(const std::string& isinCode, const std::string& description) : NPV_(0.0), isExpired_(false), isinCode_(isinCode),
description_(description), calculated(false) {}
virtual ~Instrument() {}
// inline definitions
// returns the ISIN code of the instrument, when given.
inline std::string isinCode() const {
return isinCode_;
}
// returns a brief textual description of the instrument.
inline std::string description() const {
return description_;
}
// returns the net present value of the instrument.
inline double NPV() const {
calculate();
return (isExpired_ ? 0.0 : NPV_);
}
// returns whether the instrument is still tradable.
inline bool isExpired() const {
calculate();
return isExpired_;
}
// updates dependent instrument classes
inline void update() {
calculated = false;
notifyObservers();
}
}

Paavo Helde

unread,
Sep 17, 2014, 3:21:24 PM9/17/14
to
Robert Hutchings <rm.hut...@gmail.com> wrote in
news:f72ec871-705c-4eb6...@googlegroups.com:

> My manager gave me this code today, and I am not sure understand the
> Patterns code. I know ABOUT design patterns (GoF, etc), but has
> anyone seen code like this before?

Not sure what exactly you do not understand. You only showed Instrument
code, not Patterns code (which is presumably a namespace or another class
somewhere else). Also, it looks like you have truncated the example and
kept only least interesting parts.

The code is using superfluent 'inline' keywords and does not use
'virtual' or 'override' keywords although it allegedly should override
some virtual functions ("It implements the Observable interface"). I
suggest first to delete the 'inline' keywords and add 'override' keywords
where appropriate, then it ought to become a bit clearer.

hth
Paavo


>
> ***********************************************************************

Robert Hutchings

unread,
Sep 17, 2014, 3:27:21 PM9/17/14
to
OK, thank you Paavo!

Ian Collins

unread,
Sep 17, 2014, 3:42:16 PM9/17/14
to
Robert Hutchings wrote:
> My manager gave me this code today, and I am not sure understand the Patterns code. I know ABOUT design patterns (GoF, etc), but has anyone seen code like this before?
>
> **********************************************************************************
> Abstract Instrument class
> This class is purely abstract and defines the interface of concrete instruments
> which will be derived from this one. It implements the Observable interface

How can something be "purely abstract" and implement an interface?

--
Ian Collins

Robert Hutchings

unread,
Sep 17, 2014, 3:49:18 PM9/17/14
to
I am not sure Ian. My boss did not give me enough of the code-base (headers and/or other .cpp files). I understand the Observer design pattern, but, as you say, there are some questionable statements in this code...

Ian Collins

unread,
Sep 17, 2014, 3:50:40 PM9/17/14
to
Please learn how to quote!

--
Ian Collins

Paavo Helde

unread,
Sep 17, 2014, 4:24:38 PM9/17/14
to
Robert Hutchings <rm.hut...@gmail.com> wrote in
news:5db1eec6-0d20-420d...@googlegroups.com:

> My boss did not give me enough of the code-base
> (headers and/or other .cpp files).

So ... why don't you check them out from the code repository?

Cheers
Paavo

Robert Hutchings

unread,
Sep 17, 2014, 4:32:54 PM9/17/14
to
> Please learn how to quote!
>

OK, sorry.

Robert Hutchings

unread,
Sep 17, 2014, 4:36:27 PM9/17/14
to

> So ... why don't you check them out from the code repository?
>

Yes, I will. I work in a, shall we say, "controlled" environment, so I will have to "request" additional code from our Version Control Admin....

Paavo Helde

unread,
Sep 17, 2014, 4:46:23 PM9/17/14
to
Robert Hutchings <rm.hut...@gmail.com> wrote in
news:331f0027-fe7e-4d5b...@googlegroups.com:
Wow! I foresee many inspiring stories for http://thedailywtf.com

Cheers
Paavo



Robert Hutchings

unread,
Sep 17, 2014, 4:52:32 PM9/17/14
to
> Wow! I foresee many inspiring stories for http://thedailywtf.com
>

LOL. WELL, you guys were right. C++ is NOT fast enough for "Ultra-HFT", in which FGPA modules are co-located with the exchanges. Now I am being asked to learn Verilog using a FGPA simulator...<argh>

Paavo Helde

unread,
Sep 17, 2014, 6:46:35 PM9/17/14
to
Robert Hutchings <rm.hut...@gmail.com> wrote in
news:e4e29a82-18d8-4f64...@googlegroups.com:

> LOL. WELL, you guys were right. C++ is NOT fast enough for
> "Ultra-HFT", in which FGPA modules are co-located with the exchanges.

Of course we were right, as would have been anybody else who had taken
those 30 seconds to type "HFT C++" into Google.

Cheers
Paavo

Christopher Pisz

unread,
Sep 17, 2014, 7:33:38 PM9/17/14
to
On 9/17/2014 3:36 PM, Robert Hutchings wrote:
>
>> So ... why don't you check them out from the code repository?
>>
>
> Yes, I will. I work in a, shall we say, "controlled" environment, so I will have to "request" additional code from our Version Control Admin....
>

Sounds like a hassle. You do realize how in demand C++ programmers are
in the job market, don't you? You've given us little insight into how
your job functions, but if I don't have access to source control and you
want me to figure out other people's code, whom contradict themselves in
their comments (not uncommon) then piss off, because I can find another
job in 2 day's time.

Robert Hutchings

unread,
Sep 17, 2014, 11:49:37 PM9/17/14
to
> Sounds like a hassle. You do realize how in demand C++ programmers are
> in the job market, don't you? You've given us little insight into how
> your job functions, but if I don't have access to source control and you
> want me to figure out other people's code, whom contradict themselves in
> their comments (not uncommon) then piss off, because I can find another
> job in 2 day's time.

Yes, I tend to agree. Seems to happen frequently...


0 new messages