You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Trustin Lee <tr...@gmail.com> on 2007/07/26 03:53:52 UTC

Interesting question: does state machine hurt readability?

Hi community,

I found an interesting thread related with MINA:

http://www.javalobby.org/java/forums/t99219.html

Mike Heath is evangelizing MINA in the thread.  I really appreciate
his effort, and let's hope more users are interested in MINA.  Thanks,
Mike!  :)

Anyways, I'd like to ask you a question; does state machine hurt code
readibility and maintainability?

>From my experience, state machine and event-driven paradigm simplifies
implementation of protocols dramatically.

I also find well-designed state machine will not hurt code readability:

https://svn.safehaus.org/repos/asyncweb/trunk/core/src/main/java/org/safehaus/asyncweb/codec/decoder/HttpRequestDecodingState.java

I personally think it's a matter of familiarness.  I have been using
state machines and event driven model for more than 3 years, and that
might be making me very comfortable with them.

WDYT?

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: Interesting question: does state machine hurt readability?

Posted by Pat Farrell <pf...@pfarrell.com>.
Trustin Lee wrote:
> WDYT?

All computer programs are state machines, they all build on the work of 
Alan Turing.

But for folks not used to serious programming, they can be a little hard 
to approach.

Serious networking applications have to be defined in state machines.
Otherwise you get combinatorial explosions.

So to answer your direct question, they are hard to read for casual 
programmers. But that isn't the key question. They key is:
-- are the increased precision and robustness worth the approachabilty 
tradeoffs?

I usually think they do, and make FSAs a key part of my network protocols.

IMHO, YMMV, etc.

-- 
Pat Farrell
http://www.pfarrell.com/


Re: Interesting question: does state machine hurt readability?

Posted by Emmanuel Lecharny <el...@gmail.com>.
Like a State Machine ! (James brown)

On 7/26/07, Alex Karasulu <ak...@apache.org> wrote:
> Likewise!
>
> On 7/25/07, 向秦贤 <fy...@gmail.com> wrote:
> >
> > Just one word: Agree.
> >
> > 2007/7/26, Rodrigo Madera <ro...@gmail.com>:
> > >
> > > In my opinion, state machines are not only good but required on some
> > > contexts.
> > >
> > > The problem is how good you implement it.
> > >
> > > The MINA wiki has a tutorial explaining the mina-sm component and that
> > was
> > > something that (again, in my opinion) was too complex.
> > >
> > > Maybe a little rethinking on how mina-sm does things is needed (or maybe
> > a
> > > cleaner way to indicate states).
> > >
> > > States are known to be troublesome to implement if you don't know them
> > > well,
> > > and in Java you will see most likely a class that implements the states
> > as
> > > internal subclasses.
> > >
> > > So yes, states are sticky things, but if you do it carefully and with
> > good
> > > thinking, it makes code maintainability a snap.
> > >
> > > Just my opinion.
> > >
> > > Rodrigo
> > >
> > > On 7/25/07, Trustin Lee <tr...@gmail.com> wrote:
> > > >
> > > > Hi community,
> > > >
> > > > I found an interesting thread related with MINA:
> > > >
> > > > http://www.javalobby.org/java/forums/t99219.html
> > > >
> > > > Mike Heath is evangelizing MINA in the thread.  I really appreciate
> > > > his effort, and let's hope more users are interested in MINA.  Thanks,
> > > > Mike!  :)
> > > >
> > > > Anyways, I'd like to ask you a question; does state machine hurt code
> > > > readibility and maintainability?
> > > >
> > > > From my experience, state machine and event-driven paradigm simplifies
> > > > implementation of protocols dramatically.
> > > >
> > > > I also find well-designed state machine will not hurt code
> > readability:
> > > >
> > > >
> > > >
> > >
> > https://svn.safehaus.org/repos/asyncweb/trunk/core/src/main/java/org/safehaus/asyncweb/codec/decoder/HttpRequestDecodingState.java
> > > >
> > > > I personally think it's a matter of familiarness.  I have been using
> > > > state machines and event driven model for more than 3 years, and that
> > > > might be making me very comfortable with them.
> > > >
> > > > WDYT?
> > > >
> > > > Trustin
> > > > --
> > > > what we call human nature is actually human habit
> > > > --
> > > > http://gleamynode.net/
> > > > --
> > > > PGP Key ID: 0x0255ECA6
> > > >
> > >
> >
> >
> >
> > --
> > 致敬
> > 向秦贤
> >
>


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com

Re: Interesting question: does state machine hurt readability?

Posted by Alex Karasulu <ak...@apache.org>.
Likewise!

On 7/25/07, 向秦贤 <fy...@gmail.com> wrote:
>
> Just one word: Agree.
>
> 2007/7/26, Rodrigo Madera <ro...@gmail.com>:
> >
> > In my opinion, state machines are not only good but required on some
> > contexts.
> >
> > The problem is how good you implement it.
> >
> > The MINA wiki has a tutorial explaining the mina-sm component and that
> was
> > something that (again, in my opinion) was too complex.
> >
> > Maybe a little rethinking on how mina-sm does things is needed (or maybe
> a
> > cleaner way to indicate states).
> >
> > States are known to be troublesome to implement if you don't know them
> > well,
> > and in Java you will see most likely a class that implements the states
> as
> > internal subclasses.
> >
> > So yes, states are sticky things, but if you do it carefully and with
> good
> > thinking, it makes code maintainability a snap.
> >
> > Just my opinion.
> >
> > Rodrigo
> >
> > On 7/25/07, Trustin Lee <tr...@gmail.com> wrote:
> > >
> > > Hi community,
> > >
> > > I found an interesting thread related with MINA:
> > >
> > > http://www.javalobby.org/java/forums/t99219.html
> > >
> > > Mike Heath is evangelizing MINA in the thread.  I really appreciate
> > > his effort, and let's hope more users are interested in MINA.  Thanks,
> > > Mike!  :)
> > >
> > > Anyways, I'd like to ask you a question; does state machine hurt code
> > > readibility and maintainability?
> > >
> > > From my experience, state machine and event-driven paradigm simplifies
> > > implementation of protocols dramatically.
> > >
> > > I also find well-designed state machine will not hurt code
> readability:
> > >
> > >
> > >
> >
> https://svn.safehaus.org/repos/asyncweb/trunk/core/src/main/java/org/safehaus/asyncweb/codec/decoder/HttpRequestDecodingState.java
> > >
> > > I personally think it's a matter of familiarness.  I have been using
> > > state machines and event driven model for more than 3 years, and that
> > > might be making me very comfortable with them.
> > >
> > > WDYT?
> > >
> > > Trustin
> > > --
> > > what we call human nature is actually human habit
> > > --
> > > http://gleamynode.net/
> > > --
> > > PGP Key ID: 0x0255ECA6
> > >
> >
>
>
>
> --
> 致敬
> 向秦贤
>

Re: Interesting question: does state machine hurt readability?

Posted by 向秦贤 <fy...@gmail.com>.
Just one word: Agree.

2007/7/26, Rodrigo Madera <ro...@gmail.com>:
>
> In my opinion, state machines are not only good but required on some
> contexts.
>
> The problem is how good you implement it.
>
> The MINA wiki has a tutorial explaining the mina-sm component and that was
> something that (again, in my opinion) was too complex.
>
> Maybe a little rethinking on how mina-sm does things is needed (or maybe a
> cleaner way to indicate states).
>
> States are known to be troublesome to implement if you don't know them
> well,
> and in Java you will see most likely a class that implements the states as
> internal subclasses.
>
> So yes, states are sticky things, but if you do it carefully and with good
> thinking, it makes code maintainability a snap.
>
> Just my opinion.
>
> Rodrigo
>
> On 7/25/07, Trustin Lee <tr...@gmail.com> wrote:
> >
> > Hi community,
> >
> > I found an interesting thread related with MINA:
> >
> > http://www.javalobby.org/java/forums/t99219.html
> >
> > Mike Heath is evangelizing MINA in the thread.  I really appreciate
> > his effort, and let's hope more users are interested in MINA.  Thanks,
> > Mike!  :)
> >
> > Anyways, I'd like to ask you a question; does state machine hurt code
> > readibility and maintainability?
> >
> > From my experience, state machine and event-driven paradigm simplifies
> > implementation of protocols dramatically.
> >
> > I also find well-designed state machine will not hurt code readability:
> >
> >
> >
> https://svn.safehaus.org/repos/asyncweb/trunk/core/src/main/java/org/safehaus/asyncweb/codec/decoder/HttpRequestDecodingState.java
> >
> > I personally think it's a matter of familiarness.  I have been using
> > state machines and event driven model for more than 3 years, and that
> > might be making me very comfortable with them.
> >
> > WDYT?
> >
> > Trustin
> > --
> > what we call human nature is actually human habit
> > --
> > http://gleamynode.net/
> > --
> > PGP Key ID: 0x0255ECA6
> >
>



-- 
致敬
向秦贤

Re: Interesting question: does state machine hurt readability?

Posted by Rodrigo Madera <ro...@gmail.com>.
In my opinion, state machines are not only good but required on some
contexts.

The problem is how good you implement it.

The MINA wiki has a tutorial explaining the mina-sm component and that was
something that (again, in my opinion) was too complex.

Maybe a little rethinking on how mina-sm does things is needed (or maybe a
cleaner way to indicate states).

States are known to be troublesome to implement if you don't know them well,
and in Java you will see most likely a class that implements the states as
internal subclasses.

So yes, states are sticky things, but if you do it carefully and with good
thinking, it makes code maintainability a snap.

Just my opinion.

Rodrigo

On 7/25/07, Trustin Lee <tr...@gmail.com> wrote:
>
> Hi community,
>
> I found an interesting thread related with MINA:
>
> http://www.javalobby.org/java/forums/t99219.html
>
> Mike Heath is evangelizing MINA in the thread.  I really appreciate
> his effort, and let's hope more users are interested in MINA.  Thanks,
> Mike!  :)
>
> Anyways, I'd like to ask you a question; does state machine hurt code
> readibility and maintainability?
>
> From my experience, state machine and event-driven paradigm simplifies
> implementation of protocols dramatically.
>
> I also find well-designed state machine will not hurt code readability:
>
>
> https://svn.safehaus.org/repos/asyncweb/trunk/core/src/main/java/org/safehaus/asyncweb/codec/decoder/HttpRequestDecodingState.java
>
> I personally think it's a matter of familiarness.  I have been using
> state machines and event driven model for more than 3 years, and that
> might be making me very comfortable with them.
>
> WDYT?
>
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
>