Using aliases for better code readability(jeremyjarrell.com)

submitted by jeremyjarrelljeremyjarrell(2685) 4 years, 1 month ago

Here's a quick way to reduce overall code bloat while making your code even more readable.

2 comments |category: |Views: 9

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by aquinasaquinas(20) 4 years, 1 month ago 0

Yeah, I've never been a big fan of aliases myself. When reading the code you have classnames in your code that don't actually exist. Maybe it's just me but I find that a bit confusing.

Reply

posted by BigTunaBigTuna(219) 4 years, 1 month ago 0

@aquinas: I agree, which is why I prefer to alias the namespace rather than the class. In the linked example I'd make the declarations:

using FancyControls = FancyControlVendor.Organizer.BusinessObjects;
using Outlook = Microsoft.Outlook.Interop;

and the code:

FancyControls.Email organizerEmail = _mailBox.GetSelectedEmail();
Outlook.Email outlookEmail = new OutlookEmail();

The multipart class name is my clue to look for an alias up top.

Reply

information Login or create an account to comment on this story