The Three Phases of OOP Matter

Wednesday, August 24, 2011

Gas

public static class Logger  {

    public static void Log(string message, LogTypeEnum type) {
        // ...
    }

}

 

Liquid

public class Logger  {

    public void LogError(Exception ex) {
        // ...
    }

}

 

Solid

public class Logger : ILog, IAudit  {

    public Logger(IExceptionFormatter exceptionFormatter,
                  IStackTraceFormatter stackTraceFormatter,
                  IClock clock,
                  ITextWriter writer) {
        // ...
    }

    public void LogError(Exception ex) {
        // ...
    }
}

Comments
Dantel Wednesday, August 24, 2011
Hi,

I am stupid, what is your point with this topic?
gravatar scott Wednesday, August 24, 2011
It's an abstract post and open to interpretation.
gravatar Harry Wednesday, August 24, 2011
Since it is open to interpretation, I would say Ruby looks like liquid but have all the benefits of solid ...
scott Wednesday, August 24, 2011
@Harry: Good one! :)
Joe Wednesday, August 24, 2011
Now show all the code you would need to invoke the Log/LogError method.
gravatar JMR Wednesday, August 24, 2011
@Joe +1
Matt Thursday, August 25, 2011
I new to this, curently following the excellent Scott Allen videos from Pluralsight. But i did once do a lot of scipting in Perl.

My interpretation? Complete software over engineering
Rainier Thursday, August 25, 2011
Compromise: Liquid, but make the LogError method virtual.
gravatar Scott Koon Thursday, August 25, 2011
Plasma:

public class Logger<T> : ILog, IAudit
{

public Logger(IExceptionFormatter exceptionFormatter,
IStackTraceFormatter stackTraceFormatter,
IClock clock,
ITextWriter writer)
{
// ...
}

public void LogError(Exception ex)
{
// ...
}

public void LoggError(Expression<Action<T>> action)
{
// ...
}
}
gravatar James Curran Thursday, August 25, 2011
Real liquid....

public class Logger
{
LogTypeEnum type = LogTypeEnum.Error;
string message;
Exception ex;

public Logger Error { get { type = LogTypeEnum.Error; return this; } }
public Logger Warning { get { type = LogTypeEnum.Warning; return this; } }
public Logger Because(Exception exc) { ex = exc; return this; } }
public void Log(string message) {.....}
}
Comments are now closed.
by K. Scott Allen K.Scott Allen
My Pluralsight Courses
The Podcast!