OODP Review.

July 31st, 2006 § 1 comment § permalink

I took a three hour mini-course on OO Design Principles. Now, go brush up on your OODP and more of its acronyms.

1) Polymorphism: behavior that varies depending on the function’s class being invoked.
2) Hierarchy: a) Inheritance – allow a subclass to access members of the parent class. b) Aggregation – objects can contain one or more objects of another object.
3) Encapsulation: hide/reaveal particular details of a class.
4) Abstraction: hide the details of an subclass.
5) Objects/Classes: collection of characteristics that describe something whether it is abstract or tangible; object is an instance of a class.

SRP (Single Responsibility Principle): a class should be responsible for only one thing.
DRY (Don’t Repeat Yourself): self explanatory, don’t copy/paste.
LSP (Liskov Substitution Principle): “Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.”
DIP (Dependency Inversion Principle): “High level modules should not depend upon low level modules. Both should depend on abastractions. Abstractions should not depend of details. Details should depend on abstractions.”
OCP (Open Closed Principle): Classes, methods, functions “should be open for extension, but closed for modification.”
ISP (Interface Segregation Principle): “Clients should not be forced to depend upon interfaces that they do not use.”
CCP (Common Closed Principle): “Classes within a released component should share common closure. If one need to be changed, they all are likely to need to be changed. What affects one, affects all.”
ADP (Acyclic Dependency Principle): The dependency structure for released component must be a Directed Acyclic Graph. There can be no cycles.”
SDP (Stable Dependency Principle): “Dependencies between released components must run in the direction of stability. The dependee must be more stable than the depender.”
SAP (Stable Abstraction Principle): “The more stable a component is, the more it must consist of abstract classes. A completely stable category should consist of nothing but abstract classes.”
RREP (Reuse/Release Equivalency Principle):“The granularity of reuse is the same as the granularity of release. Only components that are released through a tracking system can be effectively reused.”

If you want to read more about any of these, go check out ObjectMontor. They have a lot more documents and articles there to read.

I hope I’m not missing any important ones, if so add some to the list.

I When, You Lose.

July 27th, 2006 § 2 comments § permalink

(9:46:28 AM) Joseph: dang you for not bringing your tie fighter so spidey could fight it
(9:46:40 AM) Joseph: where is you “country” huh?
(9:47:03 AM) Thomas: what?!
(9:47:12 AM) Joseph: o you get it
(9:48:30 AM) Thomas: lasers > web.
(9:50:33 AM) Joseph: they’re toys
(9:50:43 AM) Joseph: we’re not going into real reality
(9:50:59 AM) Joseph: i’m not saying the REAL spiderman vs. a REAL tie fighter
(9:51:05 AM) Joseph: i’m saying my toy vs yours
(9:51:06 AM) Thomas: yeah, b/c real reality…there is such a thing of spiderman and tie fighters.
(9:51:09 AM) Joseph: mine would SO when
(9:51:14 AM) Thomas: SO WHEN?
(9:51:15 AM) Thomas: haahaha
(9:51:19 AM) Joseph: hahahaha
(9:51:22 AM) Joseph: exactly

Encoding Help Needed.

July 19th, 2006 § 4 comments § permalink

Here’s the plan: There’s an XML file that contains plain text data.

[Attempt 1]: Use PHP and some simple parsing to convert the data to look pretty.
[Results]: Crazy characters like “Joan Miró” and “peoples’”

[Attempt 2]: Use C# to parse the XML and output the file.
[Results]: Crazy characters like “Joan Miró” and “peoples’”

After a bunch of research, I found that the TextWriter class can encode the file:
TextWriter tw = new StreamWriter(“fileName” + “.txt”);
TextWriter tw = new StreamWriter(“fileName” + “.txt”, false, Encoding.Default);
TextWriter tw = new StreamWriter(“fileName” + “.txt”, false, Encoding.ASCII);
TextWriter tw = new StreamWriter(“fileName” + “.txt”, false, Encoding.UTF8);

All of them didn’t work. I’ve been using Ultra Edit for a while and it can do multiple file conversions. So I give it a try…ASCII to Unicode, UTF-8 to Unicode, UTF-8 to ASCII, Unicode to ASCII, DOS to UNIX, UNIX/MAC to DOS.

It all comes down to set the C# encoding to Encoding.Default and then converting the file from UTF-8 to ASCII. There’s no other way. It sucks. Any suggestions?

This was what I originally had at the top of the XML file.
<?xml version=1.0 encoding=utf-8?>

This was what I now have at the top of the XML file.
<?xml version=1.0 encoding=utf-16?>

I also had to change the TextWriter initialization from:
TextWriter tw = new StreamWriter(“fileName” + “.txt”);

TextWriter tw = new StreamWriter(“fileName” + “.txt”, false, Encoding.Default);

Thanks, Abhi and kashif for the input.

BTW: “PHP assumes your XML is in ISO-8859-1!” Even if you have it set as UTF-8. This is also why PHP isn’t going to work for these files, BOO. If there is a real PHP solution, let me know. We’re also trying another approach using a third party PHP DB interface.

Hidden Fields Really Hidden?

July 13th, 2006 § 1 comment § permalink

I guess the developer didn’t really understand how hidden fields really behaved.

1. Right click, View Source.
2. Awesome. I saw all the values in raw text.

<INPUT TYPE=”HIDDEN” NAME=”s_id” VALUE=”[usernName]”>
<INPUT TYPE=”HIDDEN” NAME=”ControlSessionID” VALUE=”[actualSID]”>
<INPUT TYPE=”HIDDEN” NAME=”url” VALUE=”http://[serverLocation]”>
<INPUT TYPE=”HIDDEN” NAME=”DataConn_ConnectionString” VALUE=”Provider=[providerName];Data Source=[sourceName]”>
<INPUT TYPE=”HIDDEN” NAME=”Library” VALUE=”[libraryName]”>
<INPUT TYPE=”HIDDEN” NAME=”DataConn_RuntimeUserName” VALUE=”[userName]”>
<INPUT TYPE=”HIDDEN” NAME=”DataConn_RuntimePassword” VALUE=”[password]”>
<INPUT TYPE=”HIDDEN” NAME=”Development_Mode” VALUE=”N”>
<INPUT TYPE=”HIDDEN” NAME=”ViewableLocations” VALUE=”All”>
<INPUT TYPE=”HIDDEN” NAME=”ViewableRegions” VALUE=”All”>

Project BBOM, Part 3?

July 12th, 2006 § 0 comments § permalink

After the migration of my first project, I have become the owner of the mess, awesome. I’m trying to convince the manager to let me scrap it and rewrite it.

I’m currently fixing a bug that has been there for…ever. Here’s what I run into trying to find the source of the bug.

[ASP Page] 805 lines; last updated in 2003! lol.

[lines 105-112]
If (isempty(postavailable)) then
     postavailable = “true”
End if

If (postavailable = “true”) then
     postavailable = true
     postavailable = false
End If

[randomly spread through the code, more than 50 times]
If (postavailable) then
     //set variable to a value, each time a different variable…
     //set a variable to ” “
End If

Where am I?

You are currently viewing the archives for July, 2006 at thomas nguyen.