4

Where I work, we use a language for our desktop software development (Delphi) and an other for web apps (asp.net/c#). My bosses want me to implement a feature on a website but they ask me to develop it in Delphi because they think they might need it for one of our software someday.

When the same situation happened in the past, my co-worker called the Delphi DLL in his C# code, but we had multiple problems trying to debug that code.

Is it best to rewrite the feature in C# or to call a DLL?

  • Is "creating web apps" no software development for you? – Doc Brown Apr 18 '18 at 19:45
  • @DocBrown I never gave it much thought but you're right. Then I guess I should say desktop software and web apps....Sorry about that. – The herald of bad news Apr 18 '18 at 20:23
  • Short anecdote: I have a custom text format used in my workplace (which sadly could easily be represented as XML or even JSON). We develop Android, iOS, and 2 web apps (Node.js and Ruby on Rails) - 4 different languages/platforms needed to understand (parse) the text format. Even though it wasn’t complex, maintaining 4 parsers in 4 languages is really difficult, and if the iOS dev ever finds other work, we’re screwed because I don’t know Objective-C. So, long story short, if you can avoid it, it’s probably a good idea to not duplicate code in multiple languages. – Chris Cirefice Apr 21 '18 at 16:09
9

What is the nature of the code? If it's e.g. numeric computation, like encryption or image processing, it's likely easy to package into a DLL. If it's something with e.g. multi-threaded I/O, it's likely much more involved.

In the complex case, instead of a DLL, I'd rather consider a server process, with some API (REST, json-rpc, protobufs, thrift, etc). The web server part could call it via that API.

Developing and debugging each part becomes much easier, because you can do it in separation.

Duplication of code is usually a bad idea. Implementations tend to diverge with time, and to have minor discrepancies due to platform differences.

  • The code is basically classes for calendar management. It's mostly model classes – The herald of bad news Apr 18 '18 at 15:26
  • 4
    Is there any non-trivial logic behind them? If not, can they both be created programmatically from some common source, e.g. a JSON or XML Schema? – 9000 Apr 18 '18 at 15:27
  • 2
    They could be created from a common source – The herald of bad news Apr 18 '18 at 15:30
1

Duplication of code is only acceptable if the maintenance and evolvement of both the original and the duplicate is independent from each other, and if making a change on one side does not automatically require you to change the other side.

However, even if these prerequisites are given, you may still waste some synergy effects by creating a dupe.

But if your primary usage scenario is "Asp.net/c#", why not approach this the other way round as you did? Develop the feature in a separate C# DLL, and make this DLL COM-enabled (like described here), which is pretty easy in C#? Then you can reuse it in a Delphi program later (assumed "someday" will ever come).

  • Would really like to code it in C# but my bosses force me to do it in Delphi...My hands are tied – The herald of bad news Apr 18 '18 at 20:33
  • @WillLafreniere: for what reason? Demonstrate him such a DLL can be reused in Delphi, maybe that convinces him. If I got you right, C# development is done for your website in your company, so "no C# know-how" can obviously be not the reason. – Doc Brown Apr 18 '18 at 20:50
  • I tried to convince him, but I think he fears other languages than Delphi. This is the only project that isn't in Delphi. We are a small team and I think I'm the only one who knows other languages. I guess he wants someone else to be able to read the code in case I leave (but I don't think this is the right way to do it) – The herald of bad news Apr 18 '18 at 21:38
  • @WillLafreniere: if Delphi is currently the major, strategic language of your organisation, I think your boss is right. Encapsulating the Delphi code in a DLL and adding a Web API (as suggested by 9000) is a sensible approach (note you probably could also write a COM component using Delphi, but I would not expect this to be simpler). – Doc Brown Apr 19 '18 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.