SOLID Thoughts

SOLID came up again in discussion.  What is SOLID?  Well, glad you asked, because I am going to elaborate on the SOLID Principles a bit.

Initial Concept
S Single Responsibility Principle
O Open/Closed Principle
L Liskov Substitution Principle
I Interface Segregation Principle
D Dependency Inversion/Injection Principle

The Single Responsibility Principle (SRP) is stated that every object should have a single responsibility and should be entirely encapsulated by the class.  This helps keep cohesion.  Here is a short example, starting with a basic class.

public class Car
{
    decimal Gas;
    int Doors;
    int Speed;
    decimal RampJumpSpeed;
}

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }Now I will refactor a little bit to make it a bit more SRP friendly.

public class Car
{
    decimal Gas;
    int Speed;
}
 
public class DuneBuggy : Car
{
    decimal RampJumpSpeed;
}
 
public class EconomyCar : Car
{
    int Doors;
}

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

What we end up with, instead of one class, is an abstract class and two classes that have their respective methods or properties to keep the responsibilities were they need to be.

The Open Closed Principle (OCP) is one of my favorites, which states simply, that you should be able to extend a classes behavior without modifying it.  There are a couple of ways one can extend a class, by inheritance, composition, or by proxy implementation. 

The Liskov Substitution Principle (LSP) states that a derived class must be substitutable for their base classes.

The Dependency Inversion Principle (DIP) states that one should depend on abstractions and not on concrete implementations.

Finally, the Interface Segregation Principle (ISP) states that fine grain interfaces should be client specific.

So hope that helps with kicking off a basic understanding of SOLID Principles.  I will be following this entry up with some new bits in the near future related to good software design and practice.

ALT.NET Seattle

Time to rock the ALT.NET scene and head up to the conference this weekend.  I must say, out of all the conferences I have been to the ALT.NET Conference is by far one of the best.  Great minds, great attitudes, awesome chances to learn, awesome changes to expand on one’s ideas with others that hit on the same hurdles!  All in all, last year was great and I am expecting it to be a great conference this year also.

For more information check out the ALT.NET site:

To get more involved in the monthly ALT.NET events in Seattle:

If you are in the Seattle area this weekend, be sure to hit up the conference.

Techie Land Silly Questions as Promised with My 2 Cents

Last week I posted the "Techie Land Silly Questions" and promised a response.  So here it is.

Question #1:  If you did not have to work, had a few dollars stashed away so that you could live comfortably and do whatever you wanted, what would you do?  Would you still code?  Would you still create?  What would you create?  Would you be able to stay idle?

I would create fun SaaS style web apps running in the cloud.  Probably a few phone apps too.  If I made tons of extra money, ya!  If not, oh well.

I would also setup time to drift, hard core style, probably own at least 2-3 S13s, 1 370Z for road trips, and possibly either an R34 or R35 GT-R for time attacks.  The catch of course is IF there was that much money to live on.

The other bits would be to, if possible, have a country house far away from others in a tranquil and awesome place were I could think and be away from the world once in a while.  The other would be to have a modest, 1000-1400 sq ft loft or condo of some sort in an urban environment in a preferred city (like say New York, Seattle, Portland, or some place of that sort) that would allow me appropriate parking or access to transit to get to my parking for the above mentioned vehicles.

Last but not least, I would love to write tons and tons of music until forever.

So put simply, I would absolutely NOT stop coding, but I would work on a LOT of other things without a regular 8hr daily gig.  The thought is fun, but even then I'm sure one of the above things would become a "job" of sorts.  Something always is the daily job.  : )

Question #2:  Based on whatever you did with your free time, what would you title yourself?  Chief Potato Masher, Pencil Pushing Writer o? Stories, or Coffee Endeavorer o? Tastiness?

Cowboy is one I like lately.  Cept' not in the "Modern Country Cowboy music hick", but in the honest, by the earth, live by the seat of my pants, keep the holster filled with a loaded 6 shooter type of Cowboy with integrity.  Yeah, that I dig.

I suppose the other one I go by is ok, Agilist Mercenary has cool ring to it.

Webtrends Web Analytics End of Week, 26th of March 2010

Within Webtrends Insight one has the ability to check out the story, an automatically generated feature that gives a written overview of the activity on your site.  I really like this feature as it gives verbal perspective.  Below is a screen capture of my blog as of today for the last 7 days. Click on the image for a larger image for readability.

The other really great looking bit is the Visits Overview Report.  All Web Compliant, and I’d show you the page, but you have to have a Webtrends Analytics Account.  😛

That is it for this week.  I am out on vacation next week, so the blog will be nice and silent.

Techie Land Silly Questions

Ok, it is time for an off the cuff, random, oddball, just for fun blog entry.  Two questions for the readers in Internet Land.

Question #1:  If you did not have to work, had a few dollars stashed away so that you could live comfortably and do whatever you wanted, what would you do?  Would you still code?  Would you still create?  What would you create?  Would you be able to stay idle?

Question #2:  Based on whatever you did with your free time, what would you title yourself?  Chief Potato Masher, Pencil Pushing Writer o? Stories, or Coffee Endeavorer o? Tastiness?

There are a million possibilities, I would love to know what you would call yourself, so please do leave a comment or three. I will have my answers later in the week.  So stay tuned and help me out with some comments.  You can bet it will include something along the lines of what I already do, but I’ll keep it a secret until then.  : )

Sharepoint and Webtrends Analytics Ideas

 

Sharepoint 2010 has some great new features.  Especially considering some of the disturbing necessities of previous Sharepoint Versions.

The first thing I noticed was that Visual Studio 2010 has default templates for building Sharepoint Projects.  This is huge compared to the monstrous and annoying effort required for development on previous versions.

Being able to build Sharepoint Projects from Visual Studio 2010 is a huge change, enabling IT & Development Groups to actually use regular Windows 7 Machines instead of needing Windows Server operating systems and licenses to build Sharepoint Applications.  To me, this was always a non-starter, and actively discouraged Sharepoint Applications in the past ? obviously most companies had not listened to the voice of reason.  But now, I have changed to actively encouraging Sharepoint 2010 Projects now.

 

The second thing is, it is more open and easier to build public facing sites finally.  This has been desperately needed.  I am glad that it has finally become a higher priority.  Not that I totally trust the Sharepoint 2010 Server to be fully web compliant, I have seen that they’ve taken leaps ahead.

The other thing I stumbled upon recently that I had not seen was the analytics capabilities of Sharepoint 2010.  The overview is that you can get traffic, search, and inventory reports based on how much traffic the site gets, who visits the sites, and other web analytics data.  Definitely check out the blog entry "Introducing Web Analytics in Sharepoint 2010" on the Enterprise Content Management (WCM) Blog.

Between the Sharepoint Analytics, Silverlight, and offerings we provide at Webtrends we now have direct extensibility points form the internal Sharepoint Data Sources, Analytics Data Stores, temp caching and other control mechanisms within Silverlight, and much more.  What does all that techno-babble mean?  It means more data, more available faster, easier access, decreased development times, more accurate reporting, more timely reporting, and the list goes on.  Pretty much ever metric about web analytics within Sharepoint 2010 has just gotten better.

The other architectural pieces I noticed is the Sharepoint Aggregation of data is now per web application in the farm, per site collection, per site, and per search service application.  This can be broken out even further with On Demand Webtrends Analytics by providing ETL between the Sharepoint and pulling the Sharepoint or extended analytics data Webtrends provides into the Business Intelligence (BI) framework within an enterprise.  At this point I can only imagine the scale and available data points for managing enterprise collaboration, social media, and other capabilities with this combination.  I’m looking forward to seeing what kinds of ROI we can see from these integrations, whatever it is, I already know it will be measurable and I suspect substantial.

For more information about Sharepoint 2010 check out the Sharepoint Blog and for more information regarding how Webtrends can get your Sharepoint Site Analytics extended check out Webtrends Professional Services!

Are there any data points, questions, thoughts, or ideas you have about connecting Sharepoint & Analytics Data?  Anything you haven’t seen connected that should be?  Does your organization use Sharepoint, Webtrends Analytics, or other collaboration software?  Anyway, I am no shill, I am honestly interested in these connections outside of the fact I work for Webtrends.  If you have a minute, please let me know what your thoughts are on these technology connections.

Styles for XAML (Silverlight & WPF)

This is a quick walk through of how to setup things for skinning within a XAML Application.  First thing, find the App.xaml file within the WPF or Silverlight Project.

Within the App.xaml file set some default styles for your controls.  I set the following for a button, label, and border control for an application I am creating.

Button Control

<Style x:Key="ButtonStyle" TargetType="Button">
    <Setter Property="FontFamily" Value="Arial" />
    <Setter Property="FontWeight" Value="Bold" />
    <Setter Property="FontSize" Value="14" />
    <Setter Property="Width" Value="180" />
    <Setter Property="Height" Value="Auto" />
    <Setter Property="Margin" Value="8" />
    <Setter Property="Padding" Value="8" />
    <Setter Property="Foreground" Value="AliceBlue" />
    <Setter Property="Background" >
        <Setter.Value>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="Black" Offset="0" />
                <GradientStop Color="#FF5B5757" Offset="1" />
            </LinearGradientBrush>
        </Setter.Value>
    </Setter>
</Style>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Label Control

<Style x:Key="LabelStyle" TargetType="Label">
    <Setter Property="Width" Value="Auto"/>
    <Setter Property="Height" Value="28" />
    <Setter Property="Foreground" Value="Black"/>
    <Setter Property="Margin" Value="8"/>
</Style>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Border Control

<Style x:Key="BorderStyle" TargetType="Border">
    <Setter Property="BorderThickness" Value="4"/>
    <Setter Property="Width" Value="Auto"/>
    <Setter Property="Height" Value="Auto" />
    <Setter Property="Margin" Value="0,8,0,0"/>
    <Setter Property="CornerRadius" Value="18"/>
    <Setter Property="BorderBrush">
        <Setter.Value>
            <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                <GradientStop Color="CornflowerBlue" Offset="0" />
                <GradientStop Color="White" Offset="1" />
            </LinearGradientBrush>
        </Setter.Value>
    </Setter>
</Style>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

These provide good examples of setting individual properties to a default, such as;

<Setter Property="Width" Value="Auto"/>
<Setter Property="Height" Value="Auto" />

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Also for settings a more complex property, such as with a LinearGradientBrush;

<Setter Property="BorderBrush">
    <Setter.Value>
        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
            <GradientStop Color="CornflowerBlue" Offset="0" />
            <GradientStop Color="White" Offset="1" />
        </LinearGradientBrush>
    </Setter.Value>
</Setter>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

These property setters should be located between the opening and closing <Application.Resources></Application.Resources> tags.

<Application x:Class="ScorecardAndDashboard.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
    </Application.Resources>
</Application>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Now in the pages, user controls, or whatever you are marking up with XAML, for the Style Property just set a StaticResource such as shown below.

     <!-- Border Control -->
<Border Name="borderPollingFrequency" Style="{StaticResource BorderStyle}">
     <!-- Label Control -->
<Label Content="Trigger Name:" Style="{StaticResource LabelStyle}"></Label>
     <!-- Button Control -->
<Button Content="Save Schedule" Name="buttonSaveSchedule"  Style="{StaticResource ButtonStyle}" HorizontalAlignment="Right"/>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

That’s it.  Simple as that.  There are other ways to setup resource files that are separate from the App.xaml, but the App.xaml file is always a good quick place to start.  As moving the styles to a specific resource file later is a mere copy and paste.

Shout it kick it on DotNetKicks.com