C++ Code I will Never write Again...

Thursday, 3 April 2008 08:04 by frimbob
   1: void Markets::RemoveItem(AUser au)
   2: {
   3:     char YN;
   4:     int key;
   5:  
   6:     try
   7:     {
   8:         //ask for an item
   9:         cout << "please select an item to delete" ;
  10:         cin >> key;
  11:  
  12:         //cast reference to item
  13:         item* ite =(item*)lst.at(key);
  14:         //cout << ite-> << endl; 
  15:         if(ite->MaxDiscount < 0){ throw 'a'; };//end if
  16:         cout << "delete this item " << ite->Name  <<"? (y/n): ";
  17:         //following was inspired by 
  18:         //http://www.augustcouncil.com/~tgibson/tutorial/iotips.html#problems
  19:         int bad_input;
  20:         do{
  21:             bad_input=0;
  22:             std::cin >> YN;
  23:             if(!std::cin)
  24:             {
  25:                 bad_input=1;
  26:                 std::cin.clear();
  27:                 std::cin.ignore();
  28:                 
  29:             }
  30:  
  31:         }while(bad_input);
  32:         //end if inspiration
  33:                         if(YN == 'y')
  34:         {
  35:             //remove the item
  36:             cat->removeproduct(ite);
  37:         };//end if
  38:  
  39:  
  40:     }
  41:     catch(...)
  42:     {
  43:         try
  44:         {
  45:             //cast reference to catagory
  46:             catagory* tcat = (catagory*)lst.at(key); 
  47:             if(tcat->subcatagories.size()) throw 'b';
  48:  
  49:             cout << " delete this catagory " << tcat->name <<"? (y/n) " << endl;
  50:             //following was inspired by 
  51:             //http://www.augustcouncil.com/~tgibson/tutorial/iotips.html#problems
  52:             int bad_input;
  53:             do{
  54:                 bad_input=0;
  55:                 std::cin >> YN;
  56:                 if(!std::cin)
  57:                 {
  58:                     bad_input=1;
  59:                     std::cin.clear();
  60:                     std::cin.ignore();
  61:                 }
  62:  
  63:             }while(bad_input);        
  64:             //end of inspiritation
  65:                                     if(YN == 'y')
  66:             {
  67:                 //the class value cat is the parent pass this object to delete
  68:                 cat->removecatagory(tcat);
  69:             };//endif
  70:  
  71:  
  72:         }
  73:         catch (...)
  74:         {
  75:             cout << "item could not be removed press u and  to continue:" << endl;
  76:             char temp;
  77:             cin >> temp;
  78:         };//end catch
  79:  
  80:     };//end catch
  81:  
  82: };//end of remove item
 

So why did I did I create this dam thing well, I was inspired by AJAX object creation if you believe that. Since there is no function that can return the correct browser type a try loop is used until the correct object name is reached

A similar problem, I had a vector of void* pointers that need to be cast into the correct type before they could be used,the vector contained 2 different types of pointers of the item* pointer and a category* pointer, obviously the typedef would not return a correct value for a void* pointer so I had to use this ugly piece to determine the type.

My advice about University projects don't start them days before there due especially when your tired and stressed and if you wish to create a list of mixed objects, don’t use a mixed list of pointers.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   Tech Tips
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Observer Pattern

Tuesday, 18 March 2008 15:58 by Frimbob

I have been doing some reading on design patterns an in particular the Observer Pattern.

In short the pattern helps to de-couple code modules by providing a third party class that will acts as observers to concrete classes. These observes act as an intermediary to send messages from one class to another.

This avoids having to directly reference other classes using a full qualified name and thus creating a dependency.

I have found some documentation on MSDN on Implementing the observer pattern in .net.

It  appears that by using delegates and events offered by the .NET frame work that less code is required than I originally though necessary.

I might use this pattern in my OOP university project if I can get my Lecture to approve of C++/CLI over his much loved classic C++ .  

Links

[Implementing observer in .net]

http://msdn2.microsoft.com/en-us/library/ms998543.aspx

[Observer Pattern MSDN documentation]

http://msdn2.microsoft.com/en-us/library/ms978753.aspx

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Top 10 UI Design Mistakes

Wednesday, 20 February 2008 15:11 by frimbob

I was reading Jakob Nielsen alert box, yesterday and found this interesting article on the top 10 User Interface design mistakes.

One of the 'bonus mistakes' that some designers do is use reset buttons on web forms. I must reluctantly admit I am one of those designers.  On my last project I created a form reset. Thinking back now the only reason I wanted such a function was to make it easier for testing. It a mistake that I wont make again.

Another item mentioned by Jakob is that scrollbars seem to be the most often changed elements, and I tend to agree with him on that one, there is just no reason to change them but I keep seeing it done.

Its and interesting read, I would recommend it. 

[Article can be found here:]

http://www.useit.com/alertbox/application-mistakes.html

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   , , , ,
Categories:   Tech Tips
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

My C# Experience

Friday, 8 February 2008 21:05 by Frimbob

Well over the past few weeks I have been attempting to get a grasp on C# language and it was easier than I had anticipated.  With my previous work with JavaScript designing the interface to my HTPC, I  found I was able to quickly overcome the syntax obstacles.

Since JavaScript has its syntax based on C a-lot was familiar, I was very use to closing all lines with a  ';' character and opening and closing statements with '{}' blocks the comparison operators and the loop controls where second nature, I was able to avoid many of the annoyances that one finds.

Having experience with VB.Net a functionally similar language (both must comply with the CLR) I found it more a matter to learn this is the VB way now this is the C# way.

However I still firmly believe that JavaScript beats both VB and C# in terms of expression. JavaScript can do more with less, but as always with such an expressive language runtime bugs are always more prevalent.

In this regard I found C# to be more expressive than VB tight syntax, and I enjoyed the freedom away from the VB shackles without the annoyances of such a loose syntax like JavaScript.

Some books that I found Helpful.

[code Notes for C# ]

Cheap and cheerful but a quick read just like it promises with plenty of good information.

http://www.codenotes.com/books/bookAction.aspx?bookID=10

[Pro C# 2008 and the .NET 3.5 Platform,Fourth Edition]

full of advanced techniques a very well through book

http://www.apress.com/book/view/1590598849

[Accelerated C# 2008]

Another good read similar to the above book.

http://www.apress.com/book/view/1590598733

[C# School]

a free e-book from www.programmersheaven.com.

http://www.programmersheaven.com/2/CSharpBook

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   Life and Stuff | Tech Tips
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Why I love my 'Iliad E-Reader'....

Friday, 1 February 2008 20:21 by Frimbob

Every feel that books are just taking over your shelves, want to have access yo your reference materials on the run?

Well here is your answer. I have owned by one e-reader for 2 weeks now and all i can say is wow, it really is the future.

The illiad while more expensive than its rivals the amazon kindal and the Soney E-reader, It is they only reader Available in Australia.

I bought mine from dymocks for $900 AUD, expensive i know but well worth.

Unlike other e-readers the iliad is more like a pda with stylus doing most of the control.  The supported formats, out of the box are pdf, html , txt and mobie-pocket, however it will not support .lit or adobe digital formats.

However to my surprise non encrypted pdf's that require a password are supported with a virtual keyboard.

Sites like feedbook allow RSS feeds to be merged into usable content for the illiad, useful for a tech head like me. The Iliad has a Wi-Fi Connection that can connect to a home network , or by use of a travel hub an ethernet connection.

The firmware is updated often with new features there are plans by Irex (manufacture) for content downloads through a portal service but there is yet date for release. 

My experience with the battery  has found that nightly charges are needed with the average life of 10 hours while not using the wi-fi connection. Other e-readers advertise there life time in pages eg. the sony e-reader quotes 15,000 page turns.

The Iliad however is not able to manage that feat, manly due to the stylus. The cpu is required to be always waiting for commands consuming greater resources, its a fair price to pay for the extra flexibility that this device allows imop.

What gives these e-devices there long batter life compared to pda's and laptops is there screen. There is a good article on the wiki maintaned by mobile read. The short gist is the screen technology called E-ink only uses power when the screen changes state, with no back light this gives the screen the look of paper.

In my opinion one could read for 10 hours and not sustain sore eyes, try doing that on a LCD screen. The trade off is dependence on local light sources and a very slow refresh rate and its not colour.

Useful links

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   , , ,
Categories:   Life and Stuff | Tech Tips
Actions:   E-mail | Permalink | Comments (2) | Comment RSSRSS comment feed