I had a requirement of late where by I wanted to share a Master Page over many physical sub sites, i.e.

  • Main Website (www.mainsite.com)
    • Sub Site 1 (www.subsite1.com)
    • Sub Site 2 (www.subsite2.com)
  • etc…

It was at this point when I thought of virtual directories and really just, again, stood back and admired the work which must have gone into such a methodology and the output which is so simple to use and yet so powerful.  If you have not used Virtual Directories before or you have heard of them but not quite GOT what they are about or their purpose then you may find this post useful.

Ignoring the master pages for now, say that you want to share a common CSS style sheet across many different websites, with the style sheet residing inside a main website.  So here is an example folder structure of the main website or a snippet:

  • wwwroot
    • www.mainsite.com
      • assets
        • css
          • sharedStyle.css

Ok, now I zip over to my other physical web site in IIS called www.subsite1.com and before I do anything, I right click and add a virtual directory.  I give it an alias of assets and point it at the physical path of the above assets folder inside the www.mainsite.com website folder.  Now once you have done this, you will see a folder with a shortcut icon, i.e. Virtual. 

What does this mean?  Well if you then create a simple html page, and you want to include the css, your css line would be the same as the one used for the www.mainsite.com .

www.mainsite.com –> /assets/css/sharedStyle.css

www.subsite1.com –> /assets/css/sharedStyle.css

If you were to go inside the folder for www.subsite1.com inside windows explorer, all you would see is this simple html page you made, and not the actual folder you are referencing, so it is virtual in every sense, albeit 1, of the word.

So if you need to change any common styles, for the many websites which used the above style sheet in my example you have consolidated the changes to one single location.

image



IIS
Friday, February 27, 2009 9:13:58 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer

I was looking for a simple way of comparing two byte arrays and it is not as 123 as you may think as methods which you may assume would return true, DO NOT.  I found a solution that does exactly what I need and is part of the framework, and I found it on the link below.  It also contains examples at the beginning which may surprise you:

http://blog.tatham.oddie.com.au/2008/07/01/comparing-byte-arrays-in-c-or-at-least-trying-to/

To summarize the method I am speaking of is the following:

public static bool SequenceEqual<TSource>(this System.Collections.Generic.IEnumerable<TSource> first, System.Collections.Generic.IEnumerable<TSource> second)
    Member of System.Linq.Enumerable

Summary:
Determines whether two sequences are equal by comparing the elements by using the default equality comparer for their type.

And it was from a comment may by a guy calling himself RichB in the blog post above.  Great find!

Cheers,

Andrew



.NET | C#
Friday, February 20, 2009 11:17:10 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer

This is a short but one of many of a series of blog posts I would like to make which mention some of the useful features of different IDEs which I make use of.  This one is for Visual Studio:

Full Screen

View –> Full Screen (Shift + Alt + Enter)

I love this feature, so say you have a certain layout set up for a particular type of project you are i.e. testing or deving etc… and you feel you would prefer some more space to code or design with, just hit Full Screen mode and you have it, then when you exit Full Screen mode, you layout persists.  Extremely useful

//TODO : bla bla bla (TASK LIST)

This is a feature which Visual Studio automatically recognizes and places in your Task List.  May be you are reviewing someones work and instead of rtackling each point as your come across it, you are able to go through all of it making the relevant //TODO: DELETE UNUSED CODE!!  then once finished Visual Studio has compiled a nice ordered task list for you to tackle.  Great organisational feature I reckon.

Bookmarks

View –> Other Windows –> Bookmark Window

I find this feature extremely handy in a couple of immediate situations:

  1. I am tracking down a procedure in code and it spans several classes, so I want to be able to jump quickly to the relevant parts so I can analyze.
  2. I am dealing with a single but extremely long code file and to preserve my sanity I set book marks while I scan down the code.  This way I am able to jump back and fourth to parts when i need.

You can also organize your book marks into folders.  I mean you could follow a procedural approach and really go deep with these and use every time you code.  I would say overkill but if you get used to something and it works, why stop?

Encapsulate Variables

For example, right click on a private variable and encapsulate.  I think this is an extremely handy feature BUT, I do prefer the one inside Net Beans which I have detailed here: Net Beans Encapsulation Feature.  I know you can get this functionality with Refactor program etc… but I would like to focus on out of the box things, oh and ignoring the extensibility lol if I am allowed to say that :-)

Conditional Breakpoints

I like the way I can set conditional break points based on the context of the currently running code, so that I can dig into exactly what I require.  For example, If I place a breakpoint inside a for iteration, I can state that i only want the break point to be hit when the counter, lets say x, is 3 . 

Split Screen Design/Markup and Split Horizontal Screen View

I think the first is new in Visual Studio 2008, and I do no actually have much use for it, as I very rarely look at the design for a web application in the GUI, but for the likes of WPF and windows development it is a really good feature and one which i am sure many people would not like to loose.

The second is when for example you drag an editor tab to the right or left and Visual Studio gives you the option to create another window horizontally next the the original.  This is good when you need to write code with immediate reference to another context.

prop tab tab

If you type prop and then hit the tab key twice you are very conveniently given a property stub like the following:

public int MyProperty { get; set; }

The type and the property name will be like a snippet where by you can tab into and out of each whilst editing, and when complete hit return and repeat the process.  It is not very useful how ever if you want to design components and you need to raise property changed events and such things.  I have no doubt this could be achieved through reflection but me personally I would simply use the complete property syntax if required.

Export Template

File –> Export Template

This is a nice tool, where you can export either a project template or export an item template.  For example lets say I create a new MVC application and add references to the Microsoft Patterns and Practices Enterprise Library.  I would then like to export this, so i have the option of creating a new MVC site which already contains all the references I need for the EntLib.

The second option for the Item Template, for example, lets say you create a custom web control and it will require control state and also notification of post backs.  You could override the two methods for the saving and loading of control state and implement the methods for the IPostBackDataHandler.  Export this ItemTemplate and in future you can now create web control  with the above already present saving you time.  Check out my post which details what i am talking about here : Custom ASP.NET Components

Funny yet I suppose still valid point: One place i used to work they actually exported a template for an ENUM!!  Is this necessary and productive or just sheer lazy.  Can I create a file and type an enum shell just as fast? hmmm I suppose I am adding one extra step doing it my way so in those terms it is more productive. 


Thursday, February 19, 2009 4:03:11 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer

Ok, so there is no doubt that it is difficult to become a software architect and extremely difficult to become a good one.  I read people talking about experience is key, but what about the experience gathered. 

I am developing all the time, and I would class my self as a CAN DO developer who is improving each job that comes.  My issue is my inquisitiveness, in that I might have done something once before, but then I think:

“Hmm ok, but if I do it this way, or If I use this pattern or this method or this technology it will be better | it will be faster OR it will be quite cool to try even if I am unsure of the outcome!”

I have found it extremely stressful, rewarding, tiresome and fulfilling to work for myself, but in the process I have come across so many different ways to, well, SKIN A CAT.  Lets think about Object Relational Mappings ORM, now when you get to this juncture what do you choose:

  1. Create your own, writing it by hand.
    1. Well this sounds fun, but unless you are planning on working with a small data store you have quite a task ahead of you. 
  2. Create a dynamic one through reflection
    1. This is one approach recommended by the Patterns of Enterprise Architecture By Martin Fowler
  3. Create a Code Generation Policy.
    1. Now if you combine the following then you will both learn and have an extremely useful tool in which to create your ORM for present and future projects.:
      1. Point 1 above
      2. A code generation tool e.g. Code Smith
      3. Some time to learn the syntax of the Code Generator
  4. Using a Sub Framework for the ORM e.g. NHibernate, NetTiers, CLSA etc…
    1. Again you would combine this point with a code generator, or you could create by hand.  Would get tedious and prone to human error though
  5. Use ADO.NET
    1. Another option which is recommended by Martin Fowler.  ADO.NET is an extremely powerful way to work with Disconnected Data.
  6. Use LINQ to SQL
    1. Great tool, although I have read that its future is uncertain and the focus will be directed on the ADO.NET Entity Framework.  I love the delayed execution and also the PIPES and FILTERS pattern.
  7. Use the ADO.NET Entity Framework
    1. From my initial exposure, I have found this to be quite amazing.  My first exposure to it has been coupled with ASP.NET Dynamic Data.

So off the top of my head there are 7 points which can also me combined in some cases and these will handle how you communicate to your Data store, quite commonly a database.  BUT WHICH TO USE.   From a risk assessment standpoint, I think it obvious to say that 5, 6 and 7 are the least risk, as in they are tried and tested frameworks from Microsoft themselves with powerful wizards and very little setup and do not require that high a level of knowledge of programming to start using.  Using 4 and 3 together come in next with 1 and 2 bringing the most risk, BUT if you choose 1 or 2 combined with 3 then of course you have the ability to build a complete tailored approach to your Domain Model or SOA.  I am not sure if risk is the correct word, may be complexity and the requirement of experience.  I think that is a better point.

Another point is Test Driven Development.  Purists would say that you should write a test before you create the object which you want to test.  I am find with this, but what if the underlying technology you are getting into is new and you are still un aware of its capabilities.  What do you test, I would need to write some code to see its functionality first and then see where I am at with it.  Once I have an idea of what I can do, then I will then know what to test, so definitely a research stage when pursuing the bleeding edge.

I would love to find out about testing TSQL, as ,my work leads down that route often and sometimes I get stuck with a problem which requires a query that to me, is a head ache.  Ok I want everything from table A and even if it does not exists in Table B with a sub query for the conditional count yada yada yada which involves 5+ tables with complex query parameters.  Then you have the Stored procedures, the scalar, table functions, views, indexes etc…. 

I think my point with this post is the level of learning that you can get drawn into when you dig deep enough, I feel it is like you get to the edge of a cliff, and you are peering over, then all of a sudden WHOOSH, you get blown off the edge and you are surrounded with hoards of material, tutorials, reviews, white papers, books, videos, Do’s, Don’ts, Design, Discussions, Difference of opinions etc….

One thing that is always in the back of my head at the minute is I read a quote from Bjarne Strousup where he says he teaches you how to program and as a by product you learn the language.  I love this quote as it tells me that I can now apply my programming in other languages, and guess what I DO!  What a rant! Right I am signing off.  I found the following image which I thought was extremely good!

 

lightweight-system

SOURCE: http://niksilver.com/

Cheers,

Andrew


Thursday, February 12, 2009 12:43:43 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer

For developing Flash and Flex projects I use Flash Develop.  It is a lightweight, fast IDE to use for Action Script development and also some other languages.  You can find the project and downloads here:

http://www.flashdevelop.org/community/

So back to topic, when you create a new project, for example I will select a new Action Script 3 project, you will definitely want to enable tracing in your application to aid with debugging.  To get this done you first need to hop over to adobe and download the debug version of the Flash Projector and whilst there, there is no harm in getting the Browser plug-in too.  The location is here:

http://www.adobe.com/support/flashplayer/downloads.html

Once downloaded and installed, it has placed a debug exe in your Adobe Folder inside program files.  So based on this, going back to the IDE, you need to:

  • Go to the Program Settings:

image

  • Then navigate to the Flash Viewer menu tab

image

I have set my external player path as: C:\Program Files\Adobe\Adobe Flash CS4\Players\Debug\FlashPlayer.exe .  If yours differs just make sure that you simply browse and select the debug player you downloaded.

Using the trace statements will then be recorded.  P.s. not quite sure what difference the Movie Display Style makes but it obviously does something.  It is not a concern for me at present so I have not investigated.

Cheers,

Andrew


Friday, February 06, 2009 8:28:54 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer
Feb
05
2009

Where am I at?

Literally I am at my desk, looking at Windows Live writer with a bottle of Fosters with Lime in.

Programmatically lol here is my current brain dump,

The things running through my head at present are (and I do mean running or SPRINTing):

  • SCRUM
    • I am, like a lot of freelancers the Scrum Master and Team rolled into one
  • Agile Development
  • Test Driven Development
  • XP
    • Being that I am a freelance programmer you could class my team as myself and the client, the project always changes so I always want to be able to adapt for it as quick and efficiently as I can, with in boundaries:

I cannot make a car in the off chance it needs to be a boat and sail to Spain!

  • C++
    • This is a topic, Language, and gateway to something I have wanted to tackle for a while now.
  • Maths and Physics
    • This goes hand in hand with the above point I feel and with any programming language you want to take on, I mean applying it with 3D in mind is mind blowing.
  • Enterprise Architecture
  • Debugging

I mean I cannot see when these topics will stop running round my head as they are part of a complete WHOLE of programming.  Another thing which happens to me is the following: So there are lots of really interesting service api s out there like EBAY, AMAZON, BET FAIR etc…, but you look at them and then you start thinking.  it is the thinking part which restricts me lol, as I continue to think after thinking of an idea.  It is a vicious circle I need to learn to control.  BABY STEPS one might say, or ROME WAS NOT BUILT IN A DAY etc… . 

Then after Service APIs you have Software SDKs, man the choice is endless, you can NEVER EVER get bored becoming a programmer, unless you need to work, and then a task that is given to you maybe time consuming but not necessarily difficult and constraints that are on you prevent you from questioning the given methodology, you literally have to DO AS YOU ARE TOLD.

As I said this is a brain dump and things are just spewing out at present.  Another thing I like to think about is associating images with the mood I am in or the problem I am given or my view of the problem or the solution.  Standing on top of the Eiffel Tower looking to the ground saying, IS THIS A BIG ENOUGH PERSPECTIVE OF THE PROJECT, WHAT PROJECT THE PROJECT IS A DOT, TOO FAR!!! 

Well one benefit of this post is I have seen a few areas in which I would like to write a blog post about and those being the bullet points above.  I am not sure who this applies to but writing these blogs is almost therapeutic and definitely progresses the learning curve through discussion.

Cheers for now,

Andrew


Thursday, February 05, 2009 9:29:25 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer
Feb
05
2009

My First C++ Program!

I cannot count the times I have either read or heard different people making the transition from C/C++ over to .NET.  By this I do not mean they are coming over to program on Visual C++ on the .NET but rather to learn C#.  I have read and heard about a minority who would never cease their C/C++ endeavours but have ventured over to .NET as an accompaniment to there previous coding skills.  I realise that when you work for a company it is difficult to continuously hone your skills in multiple programming languages.  

To me, since I started on .NET I have always wanted to learn C/C++.  In this journey I am now actively programming in C#, Java, Action Script, JavaScript with varying strength levels with C# being my strongest.  I have found that learning the core topics of OOP bound with a solid understanding of Design Patterns and general computing that the transition becomes progressively easier when tackling a new programming language.

There are still a number I would like to experience but finding the time is really difficult, some include : SCALA, F#, RUBY, PYTHON etc… Although saying that I have heard a lot of people prototype C++ work in Python. 

So my first application is really modest and simply parses a CSV file and outputs each line, whilst separating the components.  Code below:

// CppConsole.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;

int main(){
	string line;
	ifstream myfile ("C:\\TestFile.csv");
	if(myfile.is_open()){
		try{
			while(! myfile.eof()){
				while(getline(myfile,line)){
					string tempLine;
					istringstream strStream(line);
					while(getline(strStream,tempLine,',')){
						cout<< tempLine << endl;
					}
					cout<< "################";
				}
			}
			myfile.close();
		}
		catch(exception){
			myfile.close();
		}
	}
	else cout << "Unable to open file";
	return 0;
}

I have also read articles asking the question is C++ Dead or Has it got long to live.  C++ 0X 08 – 09 is on the way with more standards, so I really feel this is a good a time as any to start learning it.  One book which I have definitely got on my list of purchases is the following by the creator of C++, which by all accounts “Teaches you to program” and learning C++ is a bi-product.  I cannot remember where I read that description but i love it, a really apt statement.

 

If you search on Amazon for books on C++ and sort by Publication Date you see loads which are future dated and on the way to the Shelves.  Another author who i am looking out for on the book shelf is Herbert Shildt.  I have his Complete Reference of Java seventh edition and it is a great resource.

Ok cheers for now,

Andrew



C++
Thursday, February 05, 2009 6:19:55 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer