ラベル Technical の投稿を表示しています。 すべての投稿を表示
ラベル Technical の投稿を表示しています。 すべての投稿を表示
木曜日, 11月 06, 2008

Mini.Programming.Practice: On Swap

Problem: Swap two numbers without using a temporary variable.
Code:
int a = 1;
int b = 2;

a = a + b;
b = a - b;
a = a - b;


Output:
a=2;b=1 ^__^

火曜日, 11月 04, 2008

Programming.Practice.#.1: A Generic List Sorter using IComparer

Problem: Create a custom class that implements the necessary interfaces to allow an array of class to be sorted.
To create this custom class, I opted to implement IComparer as I wanted to have a comparisonType wherein any class property can be used as a sort filter. The use of generic T instead of object is also a good practice to avoid comparison of 2 different types.

I created a simple Person class in which instances are the ones to be sorted later on. :D


Now for the comparer class, I added a ComparisonType property, implemented Compare method of IComparer calling CompareTo method which does the processing.

Given the ComparisonType, System.Reflection's PropertyInfo will help get the corresponding reflected property type and property value. Once the values are compared, an int value (-1, 0, 1) is returned.


And now for the Sorting itself, using a console app as a sample, I made a List of type Person, created an instance of the comparer and called the Sort method of the List. I think, this sort works like Bubble Sort calling the comparer's Compare method each time.


As for the results, here are sample outputs given different ComparisonTypes. :D
ComparisonType = "FirstName"


ComparisonType = "LastName"



So that's it! Yet, this can still be refactored. Hope this practice code can help! :D

金曜日, 10月 17, 2008

Staging is VIP.

It's been a practice in the current project team to create pseudocodes for modules with long processes. Pero at this time, code muna bago "detailed" pseudocode. DAHIL! DAHIL! umikot ulo ko kaka code ng pesteng update all na to. Lumampas sa daliri ko number of times nagedit ako ng nagedit. ,,|,,

Let me raise something about what we call as UPDATE before we get going:D

Update is not simply "to update what was modified." Hahaha. Nung binigay ung task na yan nung una, kampante pa ko dahil ung "Update" na alam ko eh modify lang talaga. hahaha. PERO MALING MALI! Pag nagupdate ka, pwedeng may MADAGDAG, MABAWAS, at/o MABAGO. Kaya, naloka ang buhay ko nung ang isang proseso eh tatlo pala talaga. wooot!

So, ang general solution ko for this eh gumamit ng VENN DIAGRAM. Ganto sia:


Given two instances of an object of same type, say A and B. A is the original object and B is the modified object. The BLUE part siginifies DELETED, RED signifies ADDED, and YELLOW signifies retained values subject to be MODIFIED.

Ang saya na nun, may base na ko. Kaso, may pasaway na isang nested object na ang ginagamit na value for equality eh nasa kaloob-looban pa nia. Ang pangalan nia ay STAGING. :)) I-associate natin sia sa PENCIL. Generally, para masabi mo na equal ang dalawang lapis, dapat same brand, same serial number. Pero sa case ko, para masabi ko na same ung 2 lapis eh dapat sa parehas na puno sila nanggaling. @#$%^&*. hahaha. So after ng matinding sakit ng ulo, nagresolve pa rin ang lola mo sa same brand, same serial number dahil nasiguro kong unique ang kind ng bawat pencil sa isang box. RAWRR.

Sana inde na sumablay dahil ayoko na ulet iedit. Masyadong paimportante. Hahaha. Kahit sa ibang bagay na imvolved si STAGING, mapapel talaga sia. Kahit si Master Pogi pinapahirapan nia. =))

Ayun. For future reference at kung sino mang magkaron ng same scenario, here's the pseudocode for a guide ^__^

HORROR OF UPDATE

Fpssshhh! :)

火曜日, 9月 30, 2008

On Computer Software's Bug Etymology

Computer related terms are usually coined from real world objects. "Mouse" is a very basic example isn't it? I remember on our Web-Based Technology class when I was in 4th year college, "cookies", "breadcrumbs" are always around the corner.

Few weeks ago while I was browsing for blogs at Simple-Talk's website, I found this interesting article by Mr. Phil Factor titled "Why do we call them 'Bugs'?" Yeah. I was put into curiosity as since I was a student up to being a developer, I always face these software errors we call as 'bugs' yet in fact, I don't know why it was called that way. And I am amused on the real story behind it.

Just redirect to the main entry and read the comments as well. This is a cool new learning for us. ^__^

I SEE DEAD PEOPLE. HEHEHE

Awwooo. Hahahaha.

火曜日, 8月 05, 2008

Today's New Learning: on Tri DES

Hehe di lang ako maka getover sa natutunan ko today kaya spill ko lang. :D

On our previous project, we used Triple DES algorithm as our cipher for encryption/decryption. Implementing Tri DES in .NET allows you to provide a private key and an initialization vector of your own choice. Hehe wala namang kaso saken kung sa code gawin encrypt/decrypt. Fallback lang ng ganun for me is pahirapan pag nagquery ka sa SQL server at puro encrypted values makikita mo. Looking at the brighter side ng ganung scenario, secured talaga kahit on the developer's end. hehehe. rawrr dami kong kwento.

so ang totoong kwento ay eto. One of my teammates is working on report builder and she uses the data of our previous project. So gaya ng sinabi kong fallback kanina, since encrypted values laging irereturn ni SQL server, encrypted values din ilalabas ni report builder unless padaanin mo ung data sa decyptor na nasa loob ng code. So para inde na ganun, naghanap kami ng way to decrypt values on sql server itself kahit inde sa sql server nagencrypt. Natuwa kami na sql server 2005 is capable of encrypting/decrypting data using Tri DES algo using symmetric keys and certificates. Hanap naman ulet kami ng way for us to provide the IV we used in the code for the decryption process kaso naiyak kami sa aming nalaman...

SQL Server 2005 101 New Learning:

"You cannot specify an initialization vector (IV) when encrypting data. An IV is automatically generated by SQL Server. The IV is used to further obfuscate the encrypted result of block ciphers such as AES and DES. The obsfucation provided by an IV helps further eliminate patterns from encrypted data that cryptanalysts can use in attempts to hack encrypted data."

-Pro T-SQL 2005 Programmer's Guide by Michael Coles


Ang saya! Ang higpit ni sql >_< ! So since inde namin magagamit ung IV na sinet namin, no choice but to pass encrypted data on code for decryption. hehehe. ayus!

Ayun! that's it for today's new learning :D:D

火曜日, 6月 24, 2008

SYKES needs SOFTWARE ENGINEERS!

Do you have C#.NET experience?

Do you have VB.NET experience?

Are you implementing OOP in your codes?

Are you using web services?

Are you building N-Tier web appplications?

Are you exploring architectures?

Would you like to work in a result oriented environment?

Would you like to experience RUP? Agile?

Would you like to build ground up enterprise web applications?

Would you like to be trained? Enhance your skillsets?

Would you like to be certified? Award you for your certifications? Are you certified?

If you are looking for new challenges to improve your skillsets, learn the latest technology, build ground up applications, work in a environment where your boss (former developer) understands that the engineer is a result oriented individual then here's a great opportunity for you

Aside from the fact that Sykes offers competitive renumeration packages and benefits. (HR can discuss this :) )

We are in need of senior positions / midlevel / entry level engineers.

Send your resumes to marikris.dimaunahan@sykes.com

水曜日, 1月 09, 2008

How To Debug ASP Classic using visual Studio .NET 2005

Debugging ASP classic scripts is not as easy as pressing F5 (Start Debugging) on your visual Studio. Hehehe. Yet, with mr. always reliable google's help, I was able to find a way! Weee. The following are the steps in order to debug ASP classic. :D

COMMERCIAL! Important Thing to consider: Your IIS Version. :D

Steps:
COMMERCIAL: ALL instructions are sequential :D

Enable Server side Debugging on the Virtual Directory
1. click Start, Select Run, type inetmgr then ok. IIS appears. :D
2. Tick local computer->Websites->Default Websites. Select the virtual directory of your application.
3. Right click the virtual directory then select Properties.
4. Under Directory Tab, find configuration button then click it.
5. Under the Debugging tab of the Application configuration window, check Enable ASP server-side script debugging.
6. click Apply-OK twice. Then close IIS window.

Enable script debugging on Internet Explorer.
1. Open IE.
2. Click Tools menu then select Internet Options.
3. Under the Advanced tab of the Internet Options window, find Browsing category and uncheck Disable Script Debugging (Internet Explorer).
4. click Apply then OK.

Now debug using Visual Studio .NEt 2005
If your IIS is 5.1, proceed to -> How to debug classic ASP pages in VS 2005: IIS 5.1

If your IIS is 6.0, proceed to -> How to debug classic ASP pages in VS 2005: IIS 6.0

Just follow Mr. Mikhail Arkhipov's instructions. ^___^

Viola! That's it for today's technical sharing :)

水曜日, 12月 05, 2007

I have learned yet I'm getting bad: A technical and personal post

3 weeks of rushing the ScoreCard ground up was a shock for me. The original team needed another resource - and I was chosen to fill in the gap. I was happy in the beginning as it is one of my short term goals to experience a ground up project yet as the days progress, I really had a hard time, not really on understanding what I am supposed to fulfill but understanding that there are really different kinds of persons. hahahayz

Before I proceed with the rants, as this blog is meant to be written for, I'd like to share what I have learned after digging my head with c# data.

- Object Oriented programming rocks. I was able to put into action what was entered then thrown out of my head during the training. I have finally appreciated the benefits of OOP in the field. Once you are able setup an object's properties and methods, BOOM! everything follows. And I'm happy that IS came up with a good programming architecture, segregating database calls from business rules from the UI codes. Such archi presents a very clean code. all you have to do is call from one layer to another. And it's easy to debug because of the organized presentation of the code.

- Manipulating Lists really made me reach brain damage level 10. As an entry level programmer, it would be ok for me to manipulate Datatables in the UI after filling it with data from the database. Yet the project chose to convert data from Datatables to List objects. @_@ I was stuck by the time I finished the 2 inner layers. I am complaining to myself and to Don that I don't know how to manipulate them and the UI's still empty. hahaha. Good thing Emorej came to the rescue. wuhooo. Thanks much to Jerome, I was able to get a grasp on what I must do. Btw, what are Lists? Same as the concept of array yet List is like numerous arrays in an array. the T corresponds to whatever object such as User. TO further elaborate, let's say an object has data something like this:
UserID UserName Role
1 Kris Student
2 Makre Teacher

Each row can be treated as an array and the List itself is the larger container containing those arrays. Due to the full understanding of this, I was able to solve the task of dynamic export of search results to excel. Thank you very to much to Google for always being reliable. :P

- By implementing IComparable interface in your classes, sorting is just a click. Thanks to Master alex for sharing!

- By pressing Ctrl+K+C, the highlighted code will be commented; The use of regions will make your code look shorter. nyahehehe; If the upper layer presents an error of '...does not contain a definition' yet you're sure you have placed a code for that, all you have to do is clean the errors from the lower layers then build. It took me a lot of time to discover the latter. hahahaha

- You'll love Visual Studio .NET's 'GO TO DEFINITION' command. You'll not have a hard time finding where a function or variable is placed. use of 'GO TO DEFINITION' superiors FIND command. Thanks to Microsoft for placing their feet on somebody like me. Y__Y

- db db db. SQL Server is robust. Thumbs up. Wala akong maishare. Master Sol did most of the DB tasks. Hmm, trivia na lang. SQL Server can directly send SMS messages. For real. ^__^

Enough for the technical side, the project is like a team building. Yet my role is to only gain information from them. wahahaha. But I was able to develop my interpersonal skills. If they were to compare me to an object, it would be a QUESTIONNAIRE. Lahat ng bagay tinatanong ko. eh kasi inde ako marunong! amp talaga.

And now for the rant! Mwahahaha I already forgot my wrath. I stood to be quiet. ahehehe.


So that's it. The project, though my participation is nothing compared to the works of mighty Jerome, is very beneficial to me. Hope more ground ups will come my way.:)

OUT.

月曜日, 11月 12, 2007

Microsoft Exams Scheduled for Discontinuation

HUWAAT? panic mode ito! hahaa. sa mga may balak na magtest ng ilang microsoft exams next year, kailangan ng mag panic at tingnan ito: http://www.microsoft.com/learning/mcpexams/status/ examstoretire.mspx at baka kasama ang itatake nio sa list ng mareretire na by March 2008.

weee. buti na lang at inde kasama ang MCSD path na itatake namin ni mommy emie next year. wee. Salamat kay Ate Mye para sa kanyang pagshare. At marapat na ipasa ito sa mga taong interesado. ^__^

火曜日, 10月 02, 2007

SQL SERVER MODE: Inserting Multiple Records Using One Insert Statement - Use of UNION ALL

My current CRF is to add 134 entries in a table. Initially, I have thought my query to be like this one:

Use Database
Insert INTO Table (Col1, Col2)
VALUES ('Hello','World');
Insert INTO Table (Col1, Col2)
VALUES ('Hello','Philippines');
Insert INTO Table (Col1, Col2)
VALUES ('Hello','Quezon City');
Insert INTO Table (Col1, Col2)
VALUES ('Hello','Gilmore');
Insert INTO Table (Col1, Col2)
VALUES ('Hello','Sykes');

kahit copy-paste lang ang gagawin ko, ang fanet na paulit-ulit si INSERT. So... I asked for google's help for this. Gusto ko na isang INSERT lang ang gagamitin ko. Fortunately, pwede ngang ISA LANG! hahaha. An alternative to repeated INSERT is the use of INSERT INTO...SELECT...UNION ALL statement.

Use Database
INSERT INTO Table (Col1, Col2)
SELECT 'Hello','World'
UNION ALL
SELECT 'Hello','Philippines'
UNION ALL
SELECT 'Hello','Quezon City'
UNION ALL
SELECT 'Hello','Gilmore'
UNION ALL
SELECT 'Hello','Sykes'
UNION ALL

hehe. kahit copy-paste sia, kung sa performance basis, the alternative way is much more efficient. the difference can be seen pag mas malaking entries ang ilalagay sa table. ayus! new learning for today. :D

Thanks to http://blog.sqlauthority.com/2007/06/08/sql-server-insert-multiple-records-using-one-insert-statement-use-of-union-all/ for this helpful article. ^__^

---
WOOOT PROGRAMMER KUNO ANG POST KO! hahaha. JUST SHARING SOMETHING VALUABLE. :D