Avi Naparstek | 2 Sep 2007 08:58
Picon
Favicon

Re: How to refactor argument validity checking?

Hi.

In general, I believe returning results via exceptions creates some 
runtime overhead (at least in .Net it does - I'm not sure about Java).
So I'd have checkIBANConstraints() return some other form of result-
code or result-structure instead of throwing exceptions. Something 
like this:

private IBANValidationResult result = new IBANValidationResult;
void checkIBANConstraints(String iban) 
{
     if(!hasValidFormat(iban))
       result.IsFormatValid = false;

     if(!hasValidChecksum(iban))
       result.IsChecksumValid = false;

     if(!thirdCondition(iban))
       result.IsThirdConditionValid = false;
}

boolean isValidIBAN()
{
     if (!result.IsFormatValid) return false;
     if (!result.IsChecksumValid) return false;
     if (!result.IsThirdConditionValid) return false;
     return true;
}

After that I might be tempted to push all the validation code into 
(Continue reading)

Richard | 3 Sep 2007 09:37
Favicon
Gravatar

dependency injection of C++ collaborators

Has anyone experimented with using template arguments as a means of
injecting collaborators into a C++ class?

For example, suppose you have:

    class Production
    {
    public:
        Production(Partner *partner) : m_partner(partner)
        {
        }

        // public interface for Production

    private:
        Partner *m_partner;
    };

Partner is a collaborator with Production that's use for Production's
lifetime.  We want to test methods on Production and inject a fake Partner
for probing.  We could make Partner's methods an interface by renaming
Partner to ProductionPartner and extracting Partner as an interface
implemented by ProductionPartner.  Now that Production partners with an
interface and we can create FakePartner that derives from Partner and
override the interface methods.

    class Partner
    {
    public:
        virtual ~Partner()  = 0;
(Continue reading)

Richard | 3 Sep 2007 09:42
Favicon
Gravatar

Re: dependency injection of C++ collaborators


In article <E1IS6V8-0000lx-00 <at> xmission.xmission.com>,
    Richard <legalize <at> xmission.com>  writes:

> Can we get the test separation *and* the speed of the original?  How
> about with a template?

This should of course be 'template <class ...> class ... { ... };':

>     template <class Partner>
>     class ProductionT
>     {
>     public:
>         Production(Partner *partner) : m_partner(partner)
>         {
>         }
>         // public interface for Production
> 
>     private:
>         Partner *m_partner;
>     };
> 
>     typedef class ProductionT<Partner> Production;
> 
>     typedef class ProductionT<FakePartner> TestProduction;

--

-- 
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
      <http://www.xmission.com/~legalize/book/download/index.html>

(Continue reading)

Anthony Williams | 3 Sep 2007 10:39
Picon
Favicon

Re: dependency injection of C++ collaborators

Richard <legalize <at> xmission.com> writes:

> Has anyone experimented with using template arguments as a means of
> injecting collaborators into a C++ class?

Yes.

> Can we get the test separation *and* the speed of the original?  How
> about with a template?
>
>     typename <class Partner>
>     class ProductionT
>     {
>     public:
>         Production(Partner *partner) : m_partner(partner)
>         {
>         }
>         // public interface for Production
>
>     private:
>         Partner *m_partner;
>     };
>
>     typedef class ProductionT<Partner> Production;
>
>     typedef class ProductionT<FakePartner> TestProduction;
>
> As long as Partner and FakePartner honor the semantics of their usage
> within the implementation of Production, then everything should be
> fine.
(Continue reading)

cfp.oopsla | 10 Sep 2007 01:38
Picon
Favicon

Final Week for Reduced Rate Registration

                           R E M I N D E R

            One Week Left for Early Registration Discount

                             ooPSLA 2007
                         October 21-25, 2007
                       Montreal, Quebec, Canada

Register for ooPSLA 2007 through September 13, 2007 and save over
$100 on your registration, plus $55 per unit on tutorials.

Surf to http://oopsla.org and take part in ooPSLA 2007!

Richard P. Gabrial
ooPSLA 2007 Conference Chair

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/refactoring/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/refactoring/join
    (Yahoo! ID required)

<*> To change settings via email:
(Continue reading)

bubbleberry | 12 Sep 2007 14:24
Picon
Favicon

question on replacing conditional logic with Strategy

Hello,

I am reading "Refactoring to Patterns" by Joshua Kerievsky and I have
a question concerning "Replace conditional logic with Strategy". In
his final code he passes Loan objects to the CapitalStrategy
sub-classes' members so they can access everything to do the
calculations. My question is why not make CapitalStrategy and it's
sub-classes utility classes (hide the constructor and make all the
methods class/static methods)? Since all they do is calculate
differently and the data is passed on to them, I don't see why
different instances would be needed.

Thank you,
Gabriel

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/refactoring/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/refactoring/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:refactoring-digest <at> yahoogroups.com 
(Continue reading)

Eric | 11 Sep 2007 19:19
Picon
Favicon

Ref++

I just following the tools section on refactoring.com, I found that the 
link refering Ref++ is no longer valid, could someone tell me where is 
the new link?

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/refactoring/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/refactoring/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:refactoring-digest <at> yahoogroups.com 
    mailto:refactoring-fullfeatured <at> yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    refactoring-unsubscribe <at> yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Richard | 12 Sep 2007 17:47
Favicon
Gravatar

Re: Ref++


In article <fc6inc+vogi <at> eGroups.com>,
    "Eric" <ruoxinchen <at> yahoo.com>  writes:

> I just following the tools section on refactoring.com, I found that the 
> link refering Ref++ is no longer valid, could someone tell me where is 
> the new link?

Looks like they guy's domain expired and he hasn't bothered to renew
it.  That tool hasn't been updated in a really long tiem as well.  I
looked at it recently, but passed it over because there's no way to
evaluate it without buying it.  For a refactoring tool that has the
potential to do a lot of damage to my source code if its buggy, I'm
not going to pay $50 (or whatever it was) to find that out, so I
passed it by.
--

-- 
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
      <http://www.xmission.com/~legalize/book/download/index.html>

        Legalize Adulthood! <http://blogs.xmission.com/legalize/>

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/refactoring/

<*> Your email settings:
    Individual Email | Traditional

(Continue reading)

Anthony Williams | 12 Sep 2007 17:49
Picon
Favicon

Re: Ref++

Richard <legalize <at> xmission.com> writes:

> In article <fc6inc+vogi <at> eGroups.com>,
>     "Eric" <ruoxinchen <at> yahoo.com>  writes:
>
>> I just following the tools section on refactoring.com, I found that the 
>> link refering Ref++ is no longer valid, could someone tell me where is 
>> the new link?
>
> Looks like they guy's domain expired and he hasn't bothered to renew
> it.  That tool hasn't been updated in a really long tiem as well.  I
> looked at it recently, but passed it over because there's no way to
> evaluate it without buying it.  For a refactoring tool that has the
> potential to do a lot of damage to my source code if its buggy, I'm
> not going to pay $50 (or whatever it was) to find that out, so I
> passed it by.

If you're using Visual Studio 2005, it might be worth trying Refactor! from
Developer Express, which is free, and supports C++ refactorings.

Anthony
--

-- 
Anthony Williams
Just Software Solutions Ltd - http://www.justsoftwaresolutions.co.uk
Registered in England, Company Number 5478976.
Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

 
Yahoo! Groups Links

(Continue reading)

Richard | 12 Sep 2007 18:14
Favicon
Gravatar

Re: Re: Ref++


In article <y7fbj33d.fsf <at> yahoo.com>,
    Anthony Williams <anthony_w.geo <at> yahoo.com>  writes:

> If you're using Visual Studio 2005, it might be worth trying Refactor! from
> Developer Express, which is free, and supports C++ refactorings.

I've evaluated Refactor!Pro, and for C++ the quality is sorely lacking.

I'm going to be getting a license for Visual Assist X which now has
some limited refactoring support.

R!P is better than nothing, but its refactorings are so buggy that you
have to manually validate everything that it does, which means that
you can't trust it to just work.  That's very annoying.  A refactoring
tool needs to be rock-solid.  And yeah, I've heard all the excuses
about C++ being hard to parse and yadda yadda yadda.  But when I sit
down and write simple code just to test the basics of the refactorings
and over half of them have errors, then that's not some obscure corner
of the C++ grammar biting you unexpectedly, that's just crap.
--

-- 
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
      <http://www.xmission.com/~legalize/book/download/index.html>

        Legalize Adulthood! <http://blogs.xmission.com/legalize/>

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
(Continue reading)


Gmane