Skip to content

Commit

Permalink
Fixing formatting and missing images
Browse files Browse the repository at this point in the history
  • Loading branch information
einari committed Feb 29, 2024
1 parent 717cb36 commit d4648d2
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 69 deletions.
2 changes: 1 addition & 1 deletion _posts/2004/05/extreme-programming-too-extreme/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "eXtreme Programming - Too extreme?"
date: "2004-05-31"
---

I'm gradually moving into being an eXtreme Programmer, takes a while to apply all practises, but I'm getting there..  One thing that kinda bugs me though; the lack of templates for existing applications / servers for helping me do what I do best : design and write code.
I'm gradually moving into being an eXtreme Programmer, takes a while to apply all practices, but I'm getting there..  One thing that kinda bugs me though; the lack of templates for existing applications / servers for helping me do what I do best : design and write code.

For one I've started using the XDE designer for .net (Rational). Really coooool tool. It comes with a lot of design patterns that are really nice. In addition it had a set of RUP features. Where did the XP features go??

Expand Down
25 changes: 10 additions & 15 deletions _posts/2004/08/persistent-objects-part-3/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,19 @@ If you look at your persistent objects a bit like facade objects, this would mak

For instance :

<table style="background-color:#f2f2f2;border:#e5e5e5 1px solid;" border="0" width="100%" cellspacing="0" cellpadding="0"><tbody><tr style="vertical-align:top;line-height:normal;"><td style="width:40px;text-align:right;"><pre style="border-right:#e7e7e7 1px solid;font-size:11px;margin:0;color:gray;font-family:courier new;padding:2px;">1
2
3
4
5
6
7
8
9</pre></td><td><pre style="margin:0;padding:2px 2px 2px 8px;"><span style="font-weight:normal;font-size:11px;color:black;font-family:Courier New;background-color:transparent;">[Persistent]
<span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">public</span> <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">class</span> MyPersistentObject : PersistentObject
```csharp
[Persistent]
public class MyPersistentObject : PersistentObject
{
[PersistentWebService(<span style="font-weight:normal;font-size:11px;color:#666666;font-family:Courier New;background-color:#e4e4e4;">"&lt;uri for webservice&gt;"</span>,<span style="font-weight:normal;font-size:11px;color:#666666;font-family:Courier New;background-color:#e4e4e4;">"get method"</span>,<span style="font-weight:normal;font-size:11px;color:#666666;font-family:Courier New;background-color:#e4e4e4;">"set method"</span>)]
<span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">public</span> <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">string</span> Name {
get { <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">return</span> <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">string</span>.Empty; }
[PersistentWebService("<uri for webservice>","get method","set method")]
public string Name
{
get { return string.Empty; }
set {}
}
}</span></pre></td></tr></tbody></table>
}
```

The DoLittle Persistency project found at GotDotNet is going in that direction. The implementation uses a PersistencySource and goes through a manager to get the Default source. The default behaviour can easily be changed by implementing your own source. This source could for instance get data from a file, if that is what you are trying to accomplish.
The DoLittle Persistency project found at GotDotNet is going in that direction. The implementation uses a PersistencySource and goes through a manager to get the Default source. The default behavior can easily be changed by implementing your own source. This source could for instance get data from a file, if that is what you are trying to accomplish.

It's a world of opportunities.. :)
97 changes: 45 additions & 52 deletions _posts/2004/08/persistent-objects/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,16 @@ Another way to go about creating a persistent object would be to do some magic i

Let's say you have an object "Customer" and you have a property "Name" that you want to map to a table with the same name and using the column with the same name. How would the following code sound to do that trick :

<table style="background-color:#f2f2f2;border:#e5e5e5 1px solid;" border="0" width="100%" cellspacing="0" cellpadding="0"><tbody><tr style="vertical-align:top;line-height:normal;"><td style="width:40px;text-align:right;"><pre style="border-right:#e7e7e7 1px solid;font-size:11px;margin:0;color:gray;font-family:courier new;padding:2px;">1
2
3
4
5
6
7
8</pre></td><td><pre style="margin:0;padding:2px 2px 2px 8px;"><span style="font-weight:normal;font-size:11px;color:black;font-family:Courier New;background-color:transparent;">[PersistentObject(<span style="font-weight:normal;font-size:11px;color:#666666;font-family:Courier New;background-color:#e4e4e4;">"Customer"</span>)]
<span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">public</span> <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">class</span> Customer : ContextBoundObject
```csharp
[PersistentObject("Customer")]
public class Customer : ContextBoundObject
{
[Column(<span style="font-weight:normal;font-size:11px;color:#666666;font-family:Courier New;background-color:#e4e4e4;">"Name"</span>)]
<span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">public</span> <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">string</span> Name {
[Column("Name")]
public string Name {
get {}
}
}</span></pre></td></tr></tbody></table>
}
```

To accomplish this, you have to use the proxy system in the remoting framework. Instead of having a server/client solution we make sure that we get a proxy no matter where it is instantiated.

Expand All @@ -37,56 +32,54 @@ We need two things to achieve this. 1. An attribute that implements the System.R

The attribute can look something like this :

<table style="background-color:#f2f2f2;border:#e5e5e5 1px solid;" border="0" width="100%" cellspacing="0" cellpadding="0"><tbody><tr style="vertical-align:top;line-height:normal;"><td style="width:40px;text-align:right;"><pre style="border-right:#e7e7e7 1px solid;font-size:11px;margin:0;color:gray;font-family:courier new;padding:2px;">1
2
3
4
5
6
7
8
9
10
11</pre></td><td><pre style="margin:0;padding:2px 2px 2px 8px;"><span style="font-weight:normal;font-size:11px;color:black;font-family:Courier New;background-color:transparent;">[AttributeUsage(AttributeTargets.Class)]
<span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">public</span> <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">class</span> PersistentObjectAttribute : ProxyAttribute
```csharp
[AttributeUsage(AttributeTargets.Class)]
public class PersistentObjectAttribute : ProxyAttribute
{
<span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">public</span> PersistentObjectAttribute(<span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">string</span> tableName) {
}</span></pre><span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">public</span> <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">override</span> MarshalByRefObject CreateInstance(Type serverType) { PersistenceProxy proxy <span style="font-weight:normal;font-size:11px;color:red;font-family:Courier New;background-color:transparent;">=</span> <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">new</span> PersistenceProxy(serverType); <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">return</span> (MarshalByRefObject)proxy.GetTransparentProxy(); } }</td></tr></tbody></table>
public PersistentObjectAttribute(string tableName)
{
}

public override MarshalByRefObject CreateInstance(Type serverType)
{
PersistenceProxy proxy = new PersistenceProxy(serverType); return (MarshalByRefObject)proxy.GetTransparentProxy();
}
}
```

The proxy could look something like this :

<table style="background-color:#f2f2f2;border:#e5e5e5 1px solid;" border="0" width="100%" cellspacing="0" cellpadding="0"><tbody><tr style="vertical-align:top;line-height:normal;"><td style="width:40px;text-align:right;"><pre style="border-right:#e7e7e7 1px solid;font-size:11px;margin:0;color:gray;font-family:courier new;padding:2px;">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18</pre></td><td><pre style="margin:0;padding:2px 2px 2px 8px;"><span style="font-weight:normal;font-size:11px;color:black;font-family:Courier New;background-color:transparent;"><span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">public</span> <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">class</span> PersistenceProxy : RealProxy
```csharp
public class PersistenceProxy : RealProxy
{
<span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">public</span> PersistenceProxy(Type type) : <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">base</span>(type) {
}</span></pre><span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">public</span> <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">override</span> IMessage Invoke(IMessage msg) { <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">if</span>( msg <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">is</span> IConstructionCallMessage ) { <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">return</span> EnterpriseServicesHelper.CreateConstructionReturnMessage((IConstructionCallMessage) msg,(MarshalByRefObject)<span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">this</span>.GetTransparentProxy()); }<div></div><span style="font-weight:normal;font-size:11px;color:green;font-family:Courier New;background-color:transparent;">// Use reflection to get the tagged properties... </span><span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">if</span>( msg.Properties[<span style="font-weight:normal;font-size:11px;color:#666666;font-family:Courier New;background-color:#e4e4e4;">"__MethodName"</span>].Equals(<span style="font-weight:normal;font-size:11px;color:#666666;font-family:Courier New;background-color:#e4e4e4;">"get_Name"</span>) ) { <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">return</span> <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">new</span> ReturnMessage(<span style="font-weight:normal;font-size:11px;color:#666666;font-family:Courier New;background-color:#e4e4e4;">"Cool Name"</span>,<span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">null</span>,0,<span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">null</span>,(IMethodCallMessage)msg); }<div></div><span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">throw</span> <span style="font-weight:normal;font-size:11px;color:blue;font-family:Courier New;background-color:transparent;">new</span> NotImplementedException(<span style="font-weight:normal;font-size:11px;color:#666666;font-family:Courier New;background-color:#e4e4e4;">"Need more logic..."</span>); } }</td></tr></tbody></table>

All you need to do is to create an instance of the Customer object and there you have your proxy. Ofcourse the solution for an entire system would include some factories for handling these objects from the DB and such, but the basics of it is pretty much as shown above.
public PersistenceProxy(Type type) : base(type)
{
}

public override IMessage Invoke(IMessage msg)
{
if( msg is IConstructionCallMessage )
{
return EnterpriseServicesHelper.CreateConstructionReturnMessage((IConstructionCallMessage) msg,(MarshalByRefObject)this.GetTransparentProxy());
}

// Use reflection to get the tagged properties...
if( msg.Properties["__MethodName"].Equals("get_Name") )
{
return new ReturnMessage("Cool Name",null,0,null,(IMethodCallMessage)msg);
}

throw new NotImplementedException("Need more logic...");
}
}
```

All you need to do is to create an instance of the Customer object and there you have your proxy. Of course the solution for an entire system would include some factories for handling these objects from the DB and such, but the basics of it is pretty much as shown above.

Another point is that all the solutions I've seen for having persistence on objects are focused on mapping tables and columns. This can be extended to include far more features than that. How about linking a property to a WebService, an ADO DataSet, a static method on another object, a file... The possibilities are endless.

At the moment I'm working on a project that will be a fully working Component for anyone to use. You'll find it at GotDotNet :



http://www.gotdotnet.com/community/workspaces/workspace.aspx?id=0bb104cb-9ebb-4fc8-947f-2f9649f412b4



The revised version of this blog's topic can be found on TheServerSide.net : [http://blog.dolittle.com/ct.ashx?id=71e1b6fd-59bf-41a5-8c33-cde01dbf9899&url=http%3a%2f%2fwww.theserverside.net%2fnews%2fthread.tss%3fthread\_id%3d28325](http://blog.dolittle.com/ct.ashx?id=71e1b6fd-59bf-41a5-8c33-cde01dbf9899&url=http%3a%2f%2fwww.theserverside.net%2fnews%2fthread.tss%3fthread_id%3d28325)
Binary file added _posts/2004/08/shooting-star/images/star.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion _posts/2004/08/shooting-star/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ But, I gotta hand it to them, being an actor or actress is not just easy money.

Anyway..  I'd really like to thank Hallmark for giving me this opportunity. Hopefully they'll come knockin' again for me to star in a movie of their choice.. :)

![](http://www.dolittle.com/photos/sample/images/89/original.aspx)
![](images/star.jpeg)

0 comments on commit d4648d2

Please sign in to comment.