bug-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++ & Hydrant


From: Alain Magloire
Subject: Re: C++ & Hydrant
Date: Fri, 9 Feb 2001 11:29:29 -0500 (EST)

> 
> I am planning on writing Hydrant in C++.  I would like to beat on some 
> wrapper classes for the mailbox.
> 
> I'm looking for some opinions:
> 
> Main include file <mailutils/mailbox.hpp>
> 
> I would like to use the mailutils:: namespace for the functions.  I am 
> also going to depend on an STL compliant implementation.  GCC 3.0 comes 
> with one, so I think that this is okay.
> 
> I will develop these in conjunction with hydrant, so the two will grow 
> together.

Good, I'm glad that you are thinking of using C++.  There is two
things that make the mailutils/mailbox code ugly(inelegant) :

- Providing support for Non-Blocking mode.
  Keeping the states was a real problem and the code could look much
  more cleaner/simpler if Blocking mode is assume.

- Using C, in OO manner.
There is nothing wrong with that if you keep things simple (i.e one
level of inheritance), and resist temptations from the dark side.

On the gtk-- philosopy page:
"Have you seen C code that simulates class hierarchies, parameterized 
types, or exceptions? Such code tend to be a complete mess of pointers, 
casts, and macros. In C++, such code can be clean and simple. Most 
importantly, the constructs have well-specified semantics rather than 
just comments explaining the intent of code fragments. What has happened 
is that the complexity has been transferred from the code to the 
language definition (and compiler)."

        Bjarne Stroustrup 

My thoughts, it is a good idea and in the short future I maybe
tempted in writing such a code, instead of wrappers, For example :

using mailutils;
{
  Mailbox mbox = new Mailbox ("pop://address@hidden", 112);
  // set the callback for getting the passwd.
  ....
  mbox->open();
  Message msg = mbox->get_message(1);
  cout << msg;
}

Or the Factory design patterns.

{
  mailutils::Mailbox mbox = new MailboxFactory ("imap://address@hidden");
  // set the callback for getting the passwd.
  ....
  mbox->open();
  cout << mbox->get_message(1);
}

Or use templates.

But if you are serious with Hydrant, I would advocate to separate
the gui(the front-end) from the mail parsing engine (the back-end).
Balsa for example is one mailer that uses this, they use libmutt as
a backend and  technically should be able to use fetchmail or (beurk !)
the c-client as the replacement backend.

And I would even go on step further with the front-end by decoupling
the windowing system, so one could use curses, gtk+, ...
depending on the need.


-- 
au revoir, alain
----
Aussi haut que l'on soit assis, on n'est toujours assis que sur son cul !!!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]