The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,403 other followers

Archive for the ‘Software Development’ Category

Reading files that are locked by other references: c# – Notepad beats them all? – Stack Overflow

Posted by jpluimers on 2018/08/16

Cool feature borrowed from Notepad, which can read files locked by other references (for instance a process having the handle open): [WayBackc# – Notepad beats them all? – Stack Overflow.

The example from the answer is in .NET, but can be used in a native environment as well (Notepad is a native application).

Notepad reads files by first mapping them into memory, rather than using the “usual” file reading mechanisms presumably used by the other editors you tried. This method allows reading of files even if they have an exclusive range-based locks.

You can achieve the same in C# with something along the lines of:

using (var f = new FileStream(processIdPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var m = MemoryMappedFile.CreateFromFile(f, null, 0, MemoryMappedFileAccess.Read, null, HandleInheritability.None, true))
using (var s = m.CreateViewStream(0, 0, MemoryMappedFileAccess.Read))
using (var r = new StreamReader(s))
{
    var l = r.ReadToEnd();
    Console.WriteLine(l);
}

Via: [WayBack] Maintaining Notepad is not a full-time job, but it’s not an empty job either – The Old New Thing

–jeroen

Posted in .NET, Delphi, Development, Software Development | Leave a Comment »

Cape Cod Gunny Does Delphi: Gunny Meets Uncle Bob – Part 1

Posted by jpluimers on 2018/08/16

I like how Michael Riley compares his learning quest of software development to things he learned in real life:

  • Gang of Four Patterns = Chess
  • POSA Patterns = Golf
  • SOLID = JJDIDTIEBUCKLE

Note that JJDIDTIEBUCKE is actually 14 parts of Marine Corps leadership.

Software development is all about learning and making connections. Like life: learn new things and relate them to existing ones each and every day.

Given Michaels military background, I understand the comparison and the reference that Eric Grange makes. I think good software development is finding the balance between guerrilla and traditional thinking. Don’t loose yourself into patterns and processes, pick the ones that fit you best at the time you use them. This requires reflection which is often neglected.

I also like the comment thread in the post, so I’ve extracted some really useful information below.

Source: [WayBackCape Cod Gunny Does Delphi: Gunny Meets Uncle Bob – Part 1

From the comments

Note I don’t agree with everything, but I they make me think about my profession.

Joseph Mitzen:

Don’t give in to the conventional thinking about “design patterns”. Design patterns are language smell. They’re a sign of places where a language is broken. They’re not some sort of gospel truth. Most of the patterns don’t even exist in languages like Lisp.

Google’s Joe Gregorio emphasized this point in a talk in 2009:

You don’t need to understand 24 patterns for a language you don’t program in to be a good programmer.

Embrace Joe Gregorio, Dr. Peter Norvig, and Paul Graham… become the anti-Hodges!

Michael Riley:

+Joseph Mitzen I agree when Martin says, “Your system architecture should be as ignorant as possible about how it is to be delivered. You should be able to deliver it as a console app, or a web app, or a thick client app, or even a web service app, without undue complication or change to the fundamental architecture.”

I agree when Martin says at a minimum software professionals should be able to describe the GoF patterns and have a working knowledge of the patterns describe in the POSA books.

My pursuit to learn Dependency Injection is taking me in directions I didn’t know about and didn’t expect I be going.Hodges is my fallback position because the only mainstream language I know is Pascal. When I see the code examples he uses I understand them… it’s the concepts I’m having a hard time with.

I just now today am learning Java. This time around it is very exciting and fun. I’m totally amazed at the NetBeans IDE. I’m very impressed with JavaDocs. At this point I’m finding myself question why I should continue to pursue Delphi.

The bottom line is this: I want to make the next release of my software able to support mobile customers, web customers, windows customers and mac customers.

I feel like I’ve been given a chance to go back to high school and start over again.

Michael Thuma:

It’s not Java that confused you. It’s the combination of the Class Library and Framework. Object Orientation simply starts with using Objects. No one needs to go further beyond, which is the original idea.

There is no such a ‘dumb’ Delphi developer for example who just uses components or the classes provided. The programming world is not divided into programmers or not. Those who define classes and provide them share a common space with those who simply use (Framework). You need to play first and play it loud.

Different example from the relational world. A DB design has nothing to do with Entity Relationship which is maybe the dominating approach. The relational model is capable of a lot more than this tiny but widely used subset.

Thinking in terms of E/R limits the scope of taking opportunities. The same way you limit yourself to one specific paradigm when it comes to programming languages. All the others make up the difference.

The Java framework is heavy. It was redesigned about 15 years ago with design patterns in mind. Design patterns were introduce to extend or put the focus on reusability which does come for anything but free even in the object oriented world. That’s why these patterns became integral part of software architecture.

Eric Grange:

All good points, but one key difference with military is that in development, Rambos routinely trounces whole armies, and not just in movies. And guerilla tactics usually win over more formal armies and approaches.

IOW shops with established methodologies are regularly overtaken by startup proof of concepts, and experienced teams are all too often outsourced by management that think they’ve found a (cheaper) guerilla team.

Don’t let that stop you from learning, but it’s a wholly different battlefield…

The comment thread also reminded me that  the GoF patterns in Delphi has moved since I wrote GoF Patterns in Delphi | Implementations of the famous Gang of Four Design Patterns in Delphi language – via Nick Hodges, so I learned this:

–jeroen

via: [WayBackLars Fosdal – Google+

Read the rest of this entry »

Posted in Dependency Injection, Design Patterns, Development, Inversion of Control / IoC, Software Development | Leave a Comment »

Have NoMessageBoxes depend on a global boolean · Issue #58 · pleriche/FastMM4 · GitHub

Posted by jpluimers on 2018/08/16

Reminder to self: [WayBackHave NoMessageBoxes depend on a global boolean · Issue #58 · pleriche/FastMM4 · GitHub

–jeroen

Posted in Delphi, Development, FastMM, Software Development | Leave a Comment »

Work around for running out of memory when building multiple projects in Delphi < 10.2

Posted by jpluimers on 2018/08/16

I found out this is a problem until at least Delphi 10.1 Berlin, but my original question was for XE8:

Is there any tool that clears the Delphi memory overhead when a “build all” switches to the next project in a project group?

XE8 constantly runs out of memory with large project groups as the memory usage keeps increasing for each project it builds in the group.

There are actually two answers:

Uwe Raabe:  Have you tried with Use MSBuild checked for each project?

Jeroen Wiert Pluimers: +Uwe Raabe Much better. Much slower too (:

and:

Torbjörn Olsson: Have you tried DDevExtensions?
There is a setting named “Release compiler unit cache before compiling”

I’ve opted for the [Archive.is] DDevExtensions; I thought this VM had it installed, but apparently I forgot installing it as [Archive.is] IDE FixPack by the same author was installed.

This is how you configure DDevExtensions:

  1. Run Delphi
  2. Choose menu “Tools”, submenu “DDevExtensions Options…”
  3. In the dialog, select “Compilation” in the list on the left
  4. Ensure “Release compiler unit cache of other projects before compiling” is checked
  5. Confirm any changes

Source: [WayBackIs there any tool that clears the Delphi memory overhead when a “build all” s…

In the comparison below:

  • watch the scale of the graphs
  • observe that DDevExtensions uses about the same memory as msbuild, but builds much faster
With "Use MSBuild externally to compile"

With “Use MSBuild externally to compile”

Regular "Build all"

Regular “Build all”

With DDevExtensions

With DDevExtensions

 

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »

A success story – kudos to ScaleMM, +André Mussche… – Ondrej Kelle – Google+

Posted by jpluimers on 2018/08/15

Though no maintenance for over 2 years, it ScaleMM seems among the fastest of Delphi memory managers: [WayBack] GitHub – andremussche/scalemm: Fast scaling memory manager for Delphi

Full story via [WayBackA success story – kudos to ScaleMM, +André Mussche… – Ondrej Kelle – Google+ at [WayBack] just tried Scaled MM – cut the time for 100k down from 51 minutes to 40 minutes. That’s with 18 (9+9) cores allocated to the app and 2 to everything else. Wow, allocating 8 + 8 and the time drops even more… – Russell Weetch

Two lessons on multi-threading here:

  • use a memory manager that copes well with threads
  • do not allocate more busy threads than available (hyper-threaded) cores

Some history (as ScaleMM, TopMM and FastMM seem to be related):

  • A bit of history here: at the time we had the mm contest. Not many people had access to 8 cores+, we had…. Andre and Ivo were both colleagues of mine at that point, although working for different companies. We needed (stock trading, Ivo and me) something to scale and Ivo wrote topmm, which still performs better on multi-cores than fastmm and has less assembler code. Andre improved on Ivo’s concepts and yes, it really outperforms fastmm on multi-cores today.
    It also out-performs most C family provided mm’s. Note I was not massively involved, but both Ivo and Andre were. And both did a proper job. So KUDOS to them.
    Note these (fastmm and topmm) were written with multi-core in mind. The practical results at the time were often under-estimated, because few people had access to the real hardware. Most of us running two cores at most. Nice to see that the concept those two programmers pursued still pays dividend in 2018!
  • Read: ScaleMM and TopMM and FastMM… Keyboard left me..
    (I wrote COMMM as a joke..!).
  • [WayBack] TopMemory v3.55. High Performance. Fully Scalable. Free. Memory Manager. for. Delphi – PDF
  • [WayBack] FPC Anagrams

–jeroen

Posted in Delphi, Development, FastMM, Software Development | Leave a Comment »

 
%d bloggers like this: