# Ruby for presentation layer, C# for business layer - how to

**URL:** <https://www.ruby-forum.com/t/ruby-for-presentation-layer-c-for-business-layer-how-to/79471>\
**Category:** Rails\
**Created:** [March 10, 2006, 2:58pm UTC](https://www.ruby-forum.com/t/ruby-for-presentation-layer-c-for-business-layer-how-to/79471 "2006-03-10T14:58:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [March 10, 2006, 2:58pm UTC](https://www.ruby-forum.com/t/ruby-for-presentation-layer-c-for-business-layer-how-to/79471/1 "2006-03-10T14:58:54Z")

</div>

For reasons not relavent, I would like to create an n-tier app as  
follows.

Data Acess layer =\> NHibernate

Business layer =\> C#

Presentation layer =\> RoR

All of which might be spread across multiple machines in each layer.

I am looking for the best way to allow RoR to talk to my business layer,  
dll’s etc hosted on another box.

The RoR box might be \*nix \ apache or windows \ IIS \ Apache.

The C# box might be mono \ \*nix or .net clr \ windows.

My immediate thought was web services to perform the execution of data  
access and business processes, but is there a better way ?

Can I instanciate remote c# objects from RoR ?

Can I get an array of data returned from c# dll ?

Many thanks for any advice

BOb

---

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [March 10, 2006, 3:19pm UTC](https://www.ruby-forum.com/t/ruby-for-presentation-layer-c-for-business-layer-how-to/79471/2 "2006-03-10T15:19:16Z")

</div>

Beggars the question why?  
(I’m assuming you already have a legacy .NET/NHibernate back-end you  
want to use otherwise this looks like a fine can of worms to open. Why  
complicate matters with multiple environments when RoR (and .NET  
actually but not as fast or fun) will do it all for you?)

Nicholas

---

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [March 10, 2006, 3:44pm UTC](https://www.ruby-forum.com/t/ruby-for-presentation-layer-c-for-business-layer-how-to/79471/3 "2006-03-10T15:44:23Z")

</div>

We were thinking that compiled dll’s and .net will be faster than  
interpreted RoR \ Ruby and also we have much more experience of C# than  
Ruby \ RoR.

We dont like [asp.net](http://asp.net) and the .net code behind style of web development.

Do you really think that Ruby can compete with C# in terms of speed and  
breadth of functionality when used to write busines classes.

I am in the process of redesigning a VB6 windows app with 150 tables

> 500k LOC into a modern n-tier browser based app.

BOb

ntollervey wrote:

> Beggars the question why?  
> (I’m assuming you already have a legacy .NET/NHibernate back-end you  
> want to use otherwise this looks like a fine can of worms to open. Why  
> complicate matters with multiple environments when RoR (and .NET  
> actually but not as fast or fun) will do it all for you?)
> 
> Nicholas

---

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [March 10, 2006, 4:35pm UTC](https://www.ruby-forum.com/t/ruby-for-presentation-layer-c-for-business-layer-how-to/79471/4 "2006-03-10T16:35:15Z")

</div>

BOb,

When run in production mode using apache etc… your rails application  
will be started as several threads at a point like the Application\_Start  
event in .NET. Only in development and testing mode is the Rails  
application continuously re-interpreted for each request. There are lots  
of good blog posts and articles about RoR performance and enhancements  
thereof (caching being the first thing to come to mind) floating around  
the Internet.

With regard to business-classes, you already have a head start with  
Active-Record. Extend these classes to include whatever “additional”  
functionality you require. But, as is usually the case with RoR, someone  
has thought of this already and there are all sorts of mix-ins and built  
in methods that will let you extend active-record to suit your  
requirements. As a professional C# dev (by day, RoR by night 🙂 ) I’d  
say active-record beats faffing about with ADO (nice though ADO is) and  
really does save time.

Hope this helps,

Nicholas

---

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [March 10, 2006, 5:19pm UTC](https://www.ruby-forum.com/t/ruby-for-presentation-layer-c-for-business-layer-how-to/79471/5 "2006-03-10T17:19:13Z")

</div>

BOb wrote:

> access and business processes, but is there a better way ?  
> If you find a better way, I’d be interested in hearing about it. I  
> currently have  
> an app running like this:

```
RoR --SOAP--> C# --Proprietary Assembly--> Proprietary Data Store

```

I briefly looked at embedding Mono as a Ruby extension so I could try to  
load the assembly and talk directly to the data store; but, didn’t think  
it  
was worth the effort since I don’t know how to use the proprietary API  
anyways.

The setup as is works pretty well from the RoR end of things; I had to  
do more work on my model, since I lose ActiveRecord’s magic. But, it  
was actually much easier than I anticipated to do so. I mimicked  
ActiveRecord’s methods in my SOAP model and was able to hook my  
view and controller up to a MySQL model to make it easier for testing  
and development and then back to the SOAP model for production.

(Actually production is currently running on the MySQL backend  
because,) The only problem so far is that the webservice was very  
slow once it actually had more than a few records. Next week we should  
have an updated web service deployed that, I’m told, is orders of  
magnitude faster.

---

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [March 10, 2006, 5:58pm UTC](https://www.ruby-forum.com/t/ruby-for-presentation-layer-c-for-business-layer-how-to/79471/6 "2006-03-10T17:58:01Z")

</div>

Take a look at John L.'s RubyCLR bridge. It’s windows only, but combine  
that with Ruby DRB and you may have a way to use .NET’s remoting w/  
Ruby.

> **[John Lam's Blog](https://www.iunknown.com/)**
>
> Since 1997

Note it’s still under very heavy development, so it may not be robust  
enough  
for your needs.

---

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [March 11, 2006, 3:20am UTC](https://www.ruby-forum.com/t/ruby-for-presentation-layer-c-for-business-layer-how-to/79471/7 "2006-03-11T03:20:18Z")

</div>

I haven’t done this with .NET, but you might investigate lightweight  
technologies like JSON, Hessian, Burlap, etc. as alternatives to SOAP  
for communicating between the layers.

dean

–  
Dean W.  
[http://www.aspectprogramming.com](http://www.aspectprogramming.com)  
[http://www.newaspects.com](http://www.newaspects.com)  
[http://www.contract4j.org](http://www.contract4j.org)
