Sunday, 7 October 2012

UML - class symbol

  • A Class is shown as a rectangle and can have three regions

  • The same class may be simply, and is typically, shown as a single region or empty set of regions

  • It is common to show only significant detail and often some or all methods and attributes are omitted
  • The exception to this are interfaces where it is necessary to detail all methods (obviously a true interface has no attributes)
Copyright © 2012 www.deanwarrenuk.com 

Friday, 5 October 2012

How to create a symbolic-link (hard-link) in Windows

Windows XP/Windows Server 2003

By default Windows XP and Windows Server 2003 do not have any utilities to make a symbolic-link. Use either linkd or junction.

  1. Download linkd from here
    http://www.microsoft.com/en-us/download/details.aspx?id=17657
  2. From the command-line type the following to create, for example, a symbolic-link called link in c:\ to the folder c:\folder.
    linkd c:\link c:\folder


    or
  3. 
    
  4. Download junction from here
    http://technet.microsoft.com/en-us/sysinternals/bb896768
  5. From the command-line type the following to create, for example, a symbolic-link called link in c:\ to the folder c:\folder.
    junction -r c:\link c:\folder

Windows Server 2008/Vista/Windows 7

Use mklink.
  1. From the command-line type the following to create, for example, a symbolic-link called link in c:\ to the folder c:\folder.
    mklink c:\link c:\folder

References

http://www.microsoft.com/en-us/download/details.aspx?id=17657
http://technet.microsoft.com/en-us/sysinternals/bb896768
http://support.microsoft.com/?kbid=205524


Tuesday, 25 September 2012

How to check for an empty array in vbscript

In the following example we exit the script with an exit code of one if myArray has zero elements i.e. myArray is empty.
If UBound(myArray) = 0 Then WScript.Quit(1)

References

http://msdn.microsoft.com/en-us/library/fhx59d0t(v=vs.84).aspx

Tuesday, 18 September 2012

UML - example Class diagram

  • Here is an example of a class diagram showing a simplified model of a hotel system. 
  • A Hotel contains one-to-many rooms. A room is either a double or single room. A Hotel can have many Customers. A customer can book many rooms.
Copyright © 2012 www.deanwarrenuk.com 

Monday, 17 September 2012

UML - what is a Class diagram

  • A class diagram describes the OO class construct and it’s relationship(s) to other classes 
  • Symbols includes: Class and Association(s) 

Gotcha

Often Class diagrams are inappropriately crammed with lots of detail for each Class and omit useful description of Class relationships

Tip

Leave the detail of attributes and methods to the implementation unless absolutely necessary, always describe relationships unless implied by the association

Copyright © 2012 www.deanwarrenuk.com 

Thursday, 13 September 2012

UML - what are the common diagrams

  • The diagrams typically fall in one of three categories: Structure, Behaviour or Requirements 
  • Structure includes: Class, Package, Component and Deployment diagrams 
  • Behaviour includes: Activity, State-chart, Sequence and Collaboration diagrams 
  • Requirements includes: Use Case 
  • There are many other diagrams…
Copyright © 2012 www.deanwarrenuk.com

Thursday, 6 September 2012

How to recursively walk a folder in C++ / Boost

Walking a folder structure in most languages is typically achieved using a recursive function or loop of some kind (although this behaviour may be wrapped and hidden from the programmer) - for C++ this is not any different. However the walking isn't the problem, rather writing a platform generic (Unix/Linux/Windows) version has been a little tricky due to C++ having no standardised support for folder/directory handling across different platforms (of course file handling is standardised.).
Boost makes this simple using it's filesystem library iterators and a very simple loop construct of your choice.

Example

This example shows a recursive walk of a folder structure printing the full path of all folders and files found.
#include <boost/filesystem.hpp>
#include <iostream>

void main()
{
    boost::filesystem::path path = boost::filesystem::current_path();
    boost::filesystem::recursive_directory_iterator itr(path);
    while (itr != boost::filesystem::recursive_directory_iterator())
    {
        std::cout << itr->path().string() << std::endl;
        ++itr;
    }
}
  1. Firstly we assume you have built the Boost filesystem library and it and it's header are appropriately defined in your project e.g. link to the library and include the header file.
  2. Next you create the iterator recursive_directory_iterator. We have loaded our iterator example with the current working directory.
  3. Finally you loop until you run out of iterators.

References

http://www.boost.org/