Archive

Archive for February, 2006

Encapsulation fundamentals

February 27, 2006 Leave a comment
Fowler writes about getter setter methods (properties) http://martinfowler.com/bliki/GetterEradicator.html. He links to some great articles on encapsulation, open closed principle, protected variation, tell don’t ask etc.
 
To quote some snippets worth remembering from Craig Larman’s article
 
"However, the term has been so widely reinterpreted as a synonym for data encapsulation that it is no longer possible to use it in its original sense without misunderstanding it."
 
in short Information Hiding != Data Encapsulation.
 
"the Color static fields red, black, white, and so forth, are extremely stable; the likelihood of instability is so low that making them private and adding accessing methods is just object purism."
 
This reminds me of something which i read in an Uncle Bob’s article on OCP. "Strategic Closure".
 
To conclude, Martin Fowlers words
 
"Allocation of behavior between objects is the essence of object-oriented design, so like any design, there isn’t a hard and fast rule – rather a judging of trade-offs. Putting the behavior in the same class as the data, what Craig Larman calls "Information Expert", is the first choice to consider. But it isn’t the only route. Layering often trumps this, many of the Gang of Four patterns separate data from behavior for particular needs. A good rule of thumb is that things that change together should be together. Data and the behavior that uses it often change together, but often you see other groupings that matter more. "
 
says it all.
 
 
So are you a purist or a pragmatist?
Advertisements

Exposing a component thru Remoting and Web Services simultaneously

February 23, 2006 Leave a comment
Interesting topic, My google search was not pointing to anything useful.
Hence I thought I’ll blog my way of doing it.
 
Server side:
Web Services usually inherit from the WebService class. This gives them direct access to HttpContext properties. But this inheritance chain is not mandated, it is optional. So no one stops your web service class (asmx codebehind) to inherit from the MarshalByRefObject. If you need access to the HttpContext properties then you still have them via HttpContext.Current.
 
Now you can also host this class from a Windows Service for Remoting.
 
Client Side:
Use a factory to get the appropriate proxy.
 
Code (Optional reading):
 
DTO:
using System;
namespace Sendhil.Samples.Dual.DTO
{
 [Serializable()]
 public class Person
 {
  public Person()
  {
   _firstName = "Sendhil Kumar";
   _lastName = "Ramalingam";
  }
  private string _firstName;
  public string FirstName
  {
   get { return _firstName; }
   set { _firstName = value; }
  }
  private string _lastName;
  public string LastName
  {
   get { return _lastName; }
   set { _lastName = value; }
  }
 }
}
 
Interface
using System;
using Sendhil.Samples.Dual.DTO;
namespace Sendhil.Samples.Dual.Interfaces
{
 public interface IHelloService
 {
  string HelloWorld(Person person);
 }
}
 
Service Class (for remoting as well as web service codebehind)
using System;
using System.Web;
using System.Web.Services;
using Sendhil.Samples.Dual.Interfaces;
using Sendhil.Samples.Dual.DTO;
namespace Sendhil.Samples.Dual.Service
{
 [WebService(Description="Hello World Remoting and Web Service Implementation (Dual)",Namespace="http://spaces.msn.com/sendhil/sendhil.samples.dual/")]
 public class HelloService : MarshalByRefObject, IHelloService
 {
  public HelloService()
  {   
  }
  [WebMethod()]
  public string HelloWorld(Person person)
  {
   return string.Format("Hello {1}, {0}", person.LastName, person.FirstName);
  }
 }
}
 
Client Side ProxyFactory
using System;
using System.Runtime.Remoting;
using Sendhil.Samples.Dual.Interfaces;
namespace Sendhil.Samples.Dual.HelloClient
{
 public class ProxyFactory
 {
  public ProxyFactory()
  {
  }
  private static WellKnownClientTypeEntry entry;
  static ProxyFactory()
  {
            entry = RemotingConfiguration.GetRegisteredWellKnownClientTypes()[0];
  }
  public static IHelloService Create(bool useWebService)
  {
   IHelloService service ;
   if(useWebService)
   {
    service = new HelloService();
    return service;
   }
   else
   {
    service  = (IHelloService)Activator.GetObject(typeof(IHelloService), entry.ObjectUrl);
    return service;
   }
  }
 }
}
 
Categories: .NET Framework

Targetting .NET Fw 1.1 from VS 2005

February 21, 2006 1 comment
A few links if you are interested in the above topic.
 
VS 2005 is a better IDE compared to VS 2003. If you need to leverage the IDE features of VS 2005 but still target .NET Fw 1.1 the links could be useful.
 
Issues still remain like
Web Project support
Partial classes wont work, hence the designer features are tough to use
 
Anyways a space to keep an eye on, in future support will definitely be better.
Categories: .NET Framework

A remoting blog

February 17, 2006 Leave a comment
 
Though not updated frequently, this blog has some great remoting stuff.
Categories: .NET Framework

Remoting and Load Balancing

February 17, 2006 Leave a comment
Categories: .NET Framework

Roses

February 14, 2006 Leave a comment
Some beautiful roses

All copyrights acknowledged, credits to the original scanners.

Categories: Entertainment

1 4 3 in 101 languages

February 14, 2006 Leave a comment
Afrikaans – Ek het jou lief
Albanian – Te dua
Arabic – Ana behibak (to male)
Arabic – Ana behibek (to female)
Armenian – Yes kez sirumen
Bambara – M’bi fe
Bangla – Aamee tuma ke bhalo baashi
Belarusian – Ya tabe kahayu
Bisaya – Nahigugma ako kanimo
Bulgarian – Obicham te
Cambodian – Bung Srorlagn Oun (to female)
Oun Srorlagn Bung (to male)
Cantonese Chinese – Ngo oiy ney a
Catalan – T’estimo
Cheyenne – Ne mohotatse
Chichewa – Ndimakukonda
Corsican – Ti tengu caru (to male)
Creol – Mi aime jou
Croatian – Volim te
Czech – Miluji te
Danish – Jeg Elsker Dig
Dutch – Ik hou van jou
English – I love you
Esperanto – Mi amas vin
Estonian – Ma armastan sind
Ethiopian – Ewedishalehu : male/female to female
Ewedihalehu: male/female to male.
Faroese – Eg elski teg
Farsi – Doset daram
Filipino – Mahal kita
Finnish – Mina rakastan sinua
French – Je t’aime, Je t’adore
Gaelic – Ta gra agam ort
Georgian – Mikvarhar
German – Ich liebe dich
Greek – S’agapo
Gujarati – Hu tumney prem karu chu
Hiligaynon – Palangga ko ikaw
Hawaiian – Aloha wau ia oi
Hebrew – Ani ohev otah (to female)
Hebrew – Ani ohev et otha (to male)
Hiligaynon – Guina higugma ko ikaw
Hindi – Hum Tumhe Pyar Karte hae
Hmong – Kuv hlub koj
Hopi – Nu’ umi unangwa’ta
Hungarian – Szeretlek
Icelandic – Eg elska tig
Ilonggo – Palangga ko ikaw
Indonesian – Saya cinta padamu
Inuit – Negligevapse
Irish – Taim i’ ngra leat
Italian – Ti amo
Japanese – Aishiteru
Kannada – Naa ninna preetisuve
Kapampangan – Kaluguran daka
Kiswahili – Nakupenda
Konkani – Tu magel moga cho
Korean – Sarang Heyo
Latin – Te amo
Latvian – Es tevi miilu
Lebanese – Bahibak
Lithuanian – Tave myliu
Malay – Saya cintakan mu / Aku cinta padamu
Malayalam – Njan Ninne Premikunnu
Mandarin Chinese – Wo ai ni
Marathi – Me tula prem karto
Mohawk – Kanbhik
Moroccan – Ana moajaba bik
Nahuatl – Ni mits neki
Navaho – Ayor anosh’ni
Nepali – Ma Timilai Maya Garchhu
Norwegian – Jeg Elsker Deg
Pandacan – Syota na kita!!
Pangasinan – Inaru Taka
Papiamento – Mi ta stimabo
Persian – Doo-set daaram
Pig Latin – Iay ovlay ouyay
Polish – Kocham Cie
Portuguese – Eu te amo
Romanian – Te ubesk
Roman Numerals – 333
Russian – Ya tebya liubliu
Scot Gaelic – Tha gradh agam ort
Serbian – Volim te
Setswana – Ke a go rata
Sign Language – ,,,/ (represents position of fingers when signing ‘I Love You’
Sindhi – Maa tokhe pyar kendo ahyan
Sioux – Techihhila
Slovak – Lu`bim ta
Slovenian – Ljubim te
Spanish – Te quiero / Te amo
Swahili – Ninapenda wewe
Swedish – Jag alskar dig
Swiss-German – Ich lieb Di
Tagalog – Mahal kita
Taiwanese – Wa ga ei li
Tahitian – Ua Here Vau Ia Oe
Tamil – Naan unnai kathalikiraen
Telugu – Nenu ninnu premistunnanu
Thai – Chan rak khun (to male)
Thai – Phom rak khun (to female)
Turkish – Seni Seviyorum
Ukrainian – Ya tebe kahayu
Urdu – mai aap say pyaar karta hoo
Vietnamese – Anh ye^u em (to female)
Vietnamese – Em ye^u anh (to male)
Welsh – ‘Rwy’n dy garu
Yiddish – Ikh hob dikh
Yoruba – Mo ni fe

Courtesy: theholidayspot.com

Categories: Entertainment