Dates and Primary Keys

I've got a story to tell :D I remembered this because one of my current coworkers asked me about the curious way I write dates in code (such as 10X23, or 10902). After telling the tale, I decided to also share my experience to you guys~

T'was a dark and stormy night..

It was a dark and stormy night by =aki-no-mia on deviantART
[/kidding]

Anyway, several months before I started in my current job, I got this project to expand an HR tracking software from a local startup. It was a fairly simple project and the company already has a small internal development team that is doing another part of the system (the Point-of-Sale, if I'm not mistaken). Not only that, but an ISO 9001 Audit was ongoing in the other departments of the company- with people rifling through databases and checking that everything has a trail (eg. properly documented).

One of the Database Tables had a column named "ID", which is the table's primary key. The data was formatted like so: 20100123, 20100202, etc. Obviously, it was in a YYYYMMDD date format, so this is what the auditor did:

1.) Change the key of one record from 20100129 to 20090101, which is a valid key
2.) Open the 2010 monthly reports.

And lo and behold, the record disappeared from the reports. It turned out that one of their developers was using the ID of the records to filter the reports:

If CDbl(Record.ID) >= 100000 Then Report.Add(Record)

I don't know if it was brilliance or plain stupidity. I guess it does work. IDs are supposed to IDentify specific records, and not keep track of dates- its data formatting does not, should NOT matter.

As a workaround, the Senior Dev (who was pissed and almost fired the dev responsible) instructed us to use the following date format: YYMDD - Two digits for the year, One AlphaNum for the month, and two digits for the day. The month AlphaNum works like so: 1 through 9 for January to September, X for October, Y for November and Z for December.

Now THAT is brilliance: It shortened the ID from 8 digits to just 5 and prevented devs from converting the IDs to numbers and using them mathematically :D

Until next time, Sayonara~

Optimus Prime (a.k.a Transformational Leadership)

Attending a seminar at Newlife is one-part worship, one-part pure content, and one-part advertisement. Anyways, me and the systems department where I'm currently employed attended this seminar there called "Transformational Leadership", sponsored (prominently) by World Vision. It was a good seminar, although the speaker (Pastor Boris Joaquin) was not very engaging, but still- I'd like to share a few thoughts about it~

Ok, what striked me the most is the 5-part "Training Cycle"
  1. "The Teaching"
    • Develop their skills through detailed instructions 
    • Stay with your "disciple" every step of the way
  2. "The Demonstration"
    • Show, don't tell
    • Let the "disciple" try their skills out in real situations
  3. "The Coaching"
    • Find their flaws, make constructive criticism 
    • Inspire your "disciple" to increase his/her skills
  4. "The Release"
    • Stay in the background, help only when necessary
    • Give the "disciple" the power to decide for him/herself 
  5. "The Next Generation" 
    • Confirm that your visions and goals are still aligned
    • Let your "disciple" spread his expertise to others through this 5-part cycle

Another topic that I liked is the transformational leadership model~ This is how I understood it..
  • Start with yourself, to give yourself some perspective. If your don't walk the talk, then you'll lose followers faster than you can gain them. [Additional Reading: Mat.3:13-4:11]
  • One-on-one with a few of your most trusted people. Don't try to "change the world" as soon as you can, start with those nearest and most open to you. [Mat.4:18-22]
  • Start building your team. Let your 'chosen few' choose their own 'chosen few', stay in the background and guide the vision of your community. [Mat.10:5-10, Mat.28:19-20]
I guess that's that, I've got an "Open Source" seminar to prep, so expect the slides about it on my next post. Until then, Sayonara :D

Object-Oriented Seminar

Slide Notes Here: http://ow.ly/2Coay
After a few weeks, I was finally able to continue my seminar on 3P.Net~ Btw, The slides above have the same opening as the last one (first three or four slides, I think) and most of the juicy parts are on the slide notes. I have already touched on Lazy Initialization and Singletons in this blog, and I've talked about object-oriented programming stuff as well, so I don't think I should more stuff in this post :D

If you have any questions, clarifications or suggestions about any of the topics I've discussed in this blog, just message me in my Google Profile, Facebook or Twitter. Until next time, sayonara~

Importing Inherited Implements

What’s the difference between Imports, Inherits and Implements?

Imports
…lets the developer USE a Namespace, using a referenced library; eg. the Math Object is under the System Namespace, so in order to use the functions that it shares, you’ll declare “Imports System.Math” somewhere in your code.You can use any library that you have referenced in your project WITHOUT using Imports keyword by typing the full class path, eg. “a = System.Math.Abs(10.2);”. By using the Imports keyword, however, you can shorten the line of code to just “a = Abs(10.2);”.

Implements
…lets the developer EXTEND a Class, using an Interface. These interfaces usually start with the capital I in front of them, and implementing one of these would force a class to use certain names and types of certain methods and properties. You have to explicitly declare these constraints, or the class will not compile. However: the Interface itself cannot contain any code, it just enforces a pattern so that other objects can call a generic interface to address multiple implementations.

Inherits
…also lets the developer EXTEND a Class, but this time using a base class. The base class are complete classes with working methods and properties. It does not enforce any constraints to the class that’s inheriting it (unlike Interfaces) so you can overload (or choose to ignore) any method you like.

~~~

An Analogy: Everyone can become Wet. Dogs are Animals. Cats are Animals. All Carnivores can eat Meat.

Now, since everyone can access the method MakeWet, then an “Imports System.Water” might have been declared, so that everyone can just call the Method “MakeWet” instead of repeatedly writing “System.Water.MakeWet”.

We can say that both Dogs and Cats implement the interface IAnimal. This way, we can give both of them the method IAnimal.Talk() and force the coder to write code inside the function. Afterwards, since all animals have the same method name ‘Talk()’, we can use them like so:
Zoo.Add(New Dog)
Zoo.Add(New Cat)
For Each Animal as IAnimal in Zoo
Animal.Talk()
End For
// Output:
// ”Woof Woof”
// ”Meow Meow”
However, all animals eat alike. Instead of copy-pasting the eat method on each animal, lets just have them inherit the Base Class clsCarnivore, which automatically gives them the method ‘EatMeat’. Of course, if an animal only eats certain kinds of meat, we can overload the method, but if not, no extra code is needed.

There, and done~! Don’t get confused.. Until next post, Sayonara~

w00+! Btw, what's the opposite of writer's block?

Ok, so I said quite a few posts back that I'm pulling back on blog posts to focus on my new job at Isuzu Automotive. However, I'm quite inspired these past few days (maybe because of the thrill of educating again), and I'm currently writing 3 blog posts for you guys ^^ Yey!

Now, I'm about finished with the first one: Inherits Implements and Imports, so that'll go up approximately tomorrow evening. One of my superiors asked me about the difference between them, and I couldn't remember off the top of my head. So I decided to do some research and write about it here.

Next is a fun post, which will also be the first post on my new (!!) blog: FinalFantasy14.Philippines. I got a Beta Key for the Square-Enix's upcoming MMORPG: Final Fantasy 14, and I'll try to document what I learn and share the experience in a filipino player's perspective.

Lastly, I'm writing something about developing Android Applications. I brought an HTC Wildfire last week, and I'm kindof intrigued with the development of Android as an operating system.

Ok, that's it! I need to go write some more~ Sayonara, for now!

Trippy Dot Net

Slide Notes Here: http://ow.ly/2qFmJ


2nd seminar in a month c-c-combo! I'm getting my old confidence back :D I'll try to schedule another one next next tuesday (which I will post here too) about Unit Testing~ But in the meantime, here's a few choice bits about my take on Exception Handling (Part 1 of my 3P.Net series):

Be wary of using Try..Catch Exception Handling! Its tempting to use the infamous "Try All, Catch Everything" mentality throughout your code, but that will cause a lot of trouble to you (and your team) in the future. How? Well, aside from a slight performance hit for every line in the try..catch (less than 1ms), by catching exceptions in the lower layers, you're depriving the upper layers from effectively resolving those errors!

An example: If the end user somehow bypasses the validation, and enter a null entry into a non-nullable field, the business logic layer would pass the wrong data to the service layer, who would then try to insert/update the data source. The data source would then issue an exception to the service layer (NullArgumentException). If you resolve the error at the service layer (Log the error then throw a message saying that there's something wrong) then the business logic layer will no longer catch the exception. However! If you let it 'bubble up' (eg. Don't try..catch it, or throw it again after catching it) to the business logic layer, you can now catch all NullArgumentExceptions, fill the null data with a default value, then resend it to the data source. The end user would'nt even know that an exception had happened.

Another thing, it's good practice to throw unresolved exceptions up towards the highest layer, which is commonly the Windows Forms layer (or ASP.Net/WPF/Silverlight layer, whichever the case). The top most layer however, should have a blanket try catch on its containers (form/page/usercontrol, whichever the case) in order to catch any stray unresolved errors that manage to bubble up to the very top. These unresolved errors, are the ones that we have to track with a Bug Tracker.

You can read more about this topics on my slides above, or you could just message me in my Google Profile, Facebook or Twitter. Until next time, sayonara~

Social Networking and Education

Slide Notes Here: http://ow.ly/2mmFT



It has been quite some time since I stood in front of a classroom filled with students. A week ago, Mam (Mich) Ramirez invited me to talk at Lyceum, and I immediately agreed- As you guys know, I like being an educator. But as I stood in front of the students, I suddenly felt fear and my heart started pounding fast.. I guess 'hindi na ko sanay' and I need to start performing talks more. I hope more opportunities like these present themselves..

Anyhow.

My talk was about how college education is not enough, how we must supplement it with knowledge available to us (free!) in the internet, and how to find these knowledge through the use of Social Networking. After that, I talked a bit about blogging (which, ironically, I'm blogging about right now) and which blogging platforms I think is the best. I'll reiterate a bit here:

1) I love Blogger. Absolutely free, No strings attached, moderately customizable and best of all: Allows Ads.
2) Wordpress: for Design Experts.  It requires a small yearly fee, but you can customize a lot of it afterwards: plugins, widgets, themes, etc. Also, a photoshop pro's dream photo blog.
3) Quick & Easy blogging at Tumblr & Posterous. These are free services, little customization (compared to Blogger and Wordpress, at least) but very clean and simple to use.
4) Make your own. You can set up a Joomla, Drupal or a Ruby on Rails web server at home or on a host, get a domain name to get a 100% fully customizable website that can breath fire (if you're a good enough programmer), but of course, you'd need to invest a lot of time, effort and cash to do so. I suggest trying out the free services first.

That's it for today~! If you guys have any questions (about the seminar, blogging or even programming) you can leave a message on my Google Profiles page, or just contact me through Facebook or Twitter. Until next time, Sayonara! *watches the latest Hitman Reborn*