Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation since 02/19/19 in all areas

  1. 25 points
    Original post: https://www.thedelphigeek.com/2019/02/design-patterns-with-delphi-book.html Hurrah, hurray, my third book is here! It’s called Hands-On Design Patterns with Delphi and (just like my first book) I wrote it for Packt Publishing. (The second book was self-published and I expect the fourth one to be, too.) As the name says, “Design Patterns with Delphi” deals with design patterns. It is a bit different from most of design pattern books and websites you will find on the Internet. Case in point A: There are no UML diagrams. I don‘t speak UML. Tried to learn it few times but for some reason the whole concept doesn‘t agree with me. If you like diagrams, don’t fear though. Any book on design patterns - and most websites covering that topic - will gladly show how any design pattern can be diagrammed. That, however, is not important and should not govern your decision to buy the book. More important is case in point B: This book speaks Delphi. All the examples are written in Delphi and language features are used to the full. I also covered few less known Delphi idioms in separate sections. You’ll still be able to follow the discussion even though you may program in a different Pascal dialect. There’s also case in point 😄 Examples make sense. I deeply dislike classical design pattern examples of the “And then we want to write this program for different toolkits and it should also be able to draw circles, not only squares” kind. Euch! I tried to find a good example for each design pattern. Admittedly, I ended with few examples that draw triangles and squares on screen (mostly because some patterns were designed specifically for solving such problems), but most of them are of a more practical nature. This book covers all three classical design pattern categories - Creational patterns, Structural patterns, and Behavioral patterns. It also discusses patterns from the newer Concurrency patterns category. At the end I threw in some borderline-pattern(ish) topics and ended with a discussion of few patterns that cannot be strictly classified as “design” patterns. In this book you’ll find: Chapter 1 An introduction to patterns. Exploration of design principles, design patterns, and idioms. A mention of anti-patterns. A short description of most important design principles. Delphi idioms: creating and destroying objects. Chapter 2 Creation patterns part 1. Singleton. Dependency injection. Lazy initialization. Object pool. Chapter 3 Creation patterns part 2. Factory method, Abstract factory, Prototype, Builder. Delphi idioms: Assign and AssignTo. Chapter 4 Structural patterns part 1. Composite. Flyweight. Marker interface. Bridge. Delphi idioms: comparers and hashers. Chapter 5 Structure patterns part 2. Adapter. Proxy. Decorator. Facade. Delphi idioms: replacing components in runtime. Also: helpers. Chapter 6 Behavioral patterns part 1. Null object. Template method. Command. State. Chapter 7 Behavioral patterns part 2. Iterator. Visitor. Observer. Memento. Delphi idioms: for .. in. Chapter 8 Concurrency patterns part 1. Locking. Lock striping. Double-checked locking. Optimistic locking. Readers-writers lock. Delphi idioms: tasks and threads. Also: bitwise operators. Chapter 9 Concurrency patterns part 2. Thread pool. Messaging. Future. Pipeline. Chapter 10 Writing Delphi programs. Event-driven programming. Actions. LiveBindings. Form inheritance. Frames. Data modules. Chapter 11 Wrapping it up. Exceptions. Debugging. Functional programming. I hope you will like this book and learn a lot from it. I know I did during the nine months I spent writing it. And if you find any bug in the code, let me know so I can correct it in the second release!
  2. 15 points
    Here is a new development snapshot of IDE Fix Pack for Rio. This version detects the WebInstaller and disables IDE Fix Pack inside the WebInstaller so that it doesn't crash the installer anymore. fastdccD103vDev.7z IDEFixPackD103RegDev.7z
  3. 14 points
    And another development snapshot is available. This time the functions in StyleUtils.inc (Vcl.Styles) got optimized what makes the UI rendering faster. IDEFixPackD103RegDev.7z fastdccD103vDev.7z
  4. 10 points
    I have started a new ICS release V8.60, not finished yet but available from SVN and the daily overnight zipped snapshot at : http://wiki.overbyte.eu/wiki/index.php/ICS_Download V8.60 is a major update added several new components and sample applications created by Magenta Systems Ltd and previously distributed separately to the ICS distribution. Bundling them with ICS makes installation and updating easier, and allows existing ICS samples to make use of some the new components, such as UTF-8 file logging. There are a lot of comments in the various SVN uploads which are included in the overnight zip file. New classes added include: TIcsBlacklist TIcsBuffLogStream TIcsFindList TIcsIpStrmLog TIcsMailQueue TIcsStringBuild TIcsTimeClient TIcsTimeServer TIcsWhoisCli and there are four new sample applications that illustrate their use: OverbyteIcsMailQuTst.dpr OverbyteIcsIpStmLogTst.dpr OverbyteIcsWhoisCliTst.dpr OverbyteIcsTimeTst.dpr Also there are major updates to OverbyteIcsSslMultiWebServ.dpr which now has almost all the functionality of my commercial web server. V8.60 will also include the Magenta File Transfer components, not finshed yet. Angus
  5. 9 points
    Welcome Everyone! Welcome to this forum intended for ICS support. Feel free to ask your ICS questions here. Before asking, search this forum and also check http://wiki.overbyte.be Please stay on topic. Use other forums for subjects not directly related to ICS. --- François PIETTE The author of the freeware Internet Component Suite (ICS) The author of the freeware multi-tier middleware MidWare http://www.overbyte.be
  6. 6 points
    System.Generics.Collections does not cause that much of a code bloat since the refactorings in XE7 - however it still causes more than it should but that is the limitation of the compiler. I did some tests with Rapid.Generics and while they are optimized for some scenarios it was not a stellar improvement over System.Generics.Collections in 10.3. And while I was doing benchmarks of those and Spring4D collections I saw that isolated benchmarks are often very much affected by certain CPU specifics - on different CPUs depending on their (non documented) behavior of the branch predictor and of course in a microbenchmark chances are high that all code fits into at least L2 cache.
  7. 6 points
    Well yes.. but it's also sad that they couldn't (wouldn't?) fix those bugs for like a decade. And for a company selling a compiler + IDE I expect them to be able to fix such bugs themselves. And even if they didn't know how to do it themselves, why didn't they include the IDEFixpack earlier? The IDEFixpack existed for many years before they decided to include it. Now that they've included it, they only seem to have included very minor fixes, because you STILL need to install the 3rd party IDEFixpack for the IDE to be somewhat stable. So to be honest I'm not really that hopeful anymore. I'd really like for Emba to (positively) surprise me with 10.4, but I'm not getting my hopes up.
  8. 6 points
    Just a note: After updating the IDE from 10.3 to 10.3.1 with the WebInstaller you need to reinstall the IDE Fix Pack development snapshot, because the WebInstaller partly uninstalled it by removing the IDEFixPackStartup.bpl from the "Known IDE Packages" registry key.
  9. 4 points
    New OmniThreadLibrary is out! Get it while it’s hot! Version 3.07.7 is mostly a bugfix release. It fixes a stupid mistake introduced in version 3.07.6 plus some other minor bugs. You can get it now on git, download the ZIP archive, install it with Delphinus or with GetIt. For more information, visit OmniThreadLibrary home page or write your question on the forum. New features [HHasenack] On XE3 and above, TOmniValue.CastTo<T> supports casting to an interface. [HHasenack] Implemented Parallel.ForEach(IEnumerator<T>) and Parallel.ForEach(IEnumerable<T>). Bug fixes If additional wait objects registered with RegisterWaitObject were constantly signalled, timers were never called. OtlParallel threads were incorrectly scheduled to the main pool instead of GlobalParallelPool unless IOmniTaskConfig.ThreadPool was used. (introduced in 3.07.6) Using Parallel.Join, .For, and .ForEach with .OnStopInvoke failed with access violation if Join/For/ForEach was not executed with .NoWait. Thread pool creation code waits for thread pool management thread to be started and initialized. Without that, CountQueued and CountExecuting may not be initialized correctly when thread pool creation code exits. [tnx to Roland Skinner]
  10. 4 points
    I think they only test on small demo projects. I believe (since embarcadero) they really focus on quality but they are not very smart when choosing what to do. When trying to optimize code they should choose to remove big bottlenecks that cost minutes before working on code to win milliseconds. They have difficulties priorizing things that for us look obvious. But there is hope, they understood someone is smarter than them and asked permission to integrate some idefixpack fixes ! I told them, "Without IDEFixPack Delphi is llike "Turbo Pascal" without the "Turbo" ! But idefixpack will allways be needed, because it also fixes some breaking bugs that would require months of waiting for an official patch.
  11. 3 points
    What's new HCL/Core Added support for TVirtualImageList Improved rendeing of images and text (align to pixel) HtPanel: added AllowScaling property. SVG: added support for "use" element. Added support for external SVG images Improved RTL support Automatic detection of RTL blocks Virtual image source for image lists on other forms, f.e. src="_forms/DataModule1/ImageList2/5" Improved emoji symbols support for VCL and FMX. Improved resize hint Added TCSSStyleSheet.GetAllClasses/GetAllIds Improved SVG rendering Added OnElementEnter/Exit event for HtPanel Added THtDocument.LoadfromStream Added THtDocument.ElementsFromPoint method returning all elements located at specified point. Empty attributes with no value now preserves their format Added support for ForeignObject tag which allows use of HTML blocks inside SVG. FMX: improved text baseline calculation Scripter: added support for list of values in case statement: case a of 1,2,3: Editor Fast Report component with visual editor and page split support (included in bundle). https://www.youtube.com/watch?v=DNAK_KR8fB0 https://delphihtmlcomponents.com/fastreport2.gif Added TDBHTMLEditor.UseOuterHTML property Added TDBHTMLEditor.NewDocumentTemplate Editor:Column widths are not preserved when copy/paste part of a table SQL Optimized schema loading queries for Oracle. Added TSQLSelectQuery.ChangeRowLimit class function. Added TSQLSelectQuery.AddJoin function https://delphihtmlcomponents.com
  12. 3 points
    Some thoughts on OpenSsl 1.1.1....We recently finished porting the OpenSsl 1.1.1a headers to Delphi for all platforms (Windows, macOS, Android, iOS and Linux, 32 and 64-bit where appropriate) and may write an article for our grijjy blog on that sometime soon. The challenge is building in a way that works for each Delphi platform, which we also did in the process. Deploying OpenSsl with your app in a way that is uniform for all platforms but does not interfere with legacy OpenSsl that is sometimes part of the OS is also a challenge. The libraries for LibSsl and LibCrypto often cause dynamic linking issues on POSIX platforms when they attempt to reference one another. We solved this with some creative linking that is platform specific. Also it isn't wired into Indy, because we don't use Indy internally, but it shouldn't be too hard (for someone else to do). The other challenge is TLS 1.3 isn't really completely working in OpenSsl 1.1.1 and has a few outstanding issues. You probably don't want to use TLS 1.3 at this time.
  13. 3 points
    hello, I did patches for MM and RTL of Win64, making Delphi windows server app flying you can check this cool library thread https://github.com/winddriver/Delphi-Cross-Socket/issues/39# Rio 10.3.1 default Server Software: CrossHttpServer/2.0 Server Hostname: 192.168.1.166 Server Port: 8000 Document Path: /hello Document Length: 11 bytes Concurrency Level: 100 Time taken for tests: 3.703 seconds Complete requests: 100000 Failed requests: 0 Keep-Alive requests: 100000 Total transferred: 14200000 bytes HTML transferred: 1100000 bytes Requests per second: **27002.22 [#/sec] (mean)** Time per request: 3.703 [ms] (mean) Time per request: 0.037 [ms] (mean, across all concurrent requests) Transfer rate: 3744.45 [Kbytes/sec] received Rio 10.3.1 with RDP patches Server Software: CrossHttpServer/2.0 Server Hostname: 192.168.1.166 Server Port: 8000 Document Path: /hello Document Length: 11 bytes Concurrency Level: 100 Time taken for tests: 1.094 seconds Complete requests: 100000 Failed requests: 0 Keep-Alive requests: 100000 Total transferred: 14200000 bytes HTML transferred: 1100000 bytes Requests per second: **91442.20 [#/sec] (mean)** Time per request: 1.094 [ms] (mean) Time per request: 0.011 [ms] (mean, across all concurrent requests) Transfer rate: 12680.46 [Kbytes/sec] received Please check my Pos() routines, should be ok If you use my patches please put a link to my website [www.dellapasqua.com](http://www.dellapasqua.com) and please, if you like, forward me some jobs internet related, fullstack, cloud, embedded, sql, I'm glad to collaborate with smart people, Delphi companies Thank you Roberto Della Pasqua RDPRTL.zip TestPOs.zip Btw. I have also zlib SIMD 5x faster than the system gzip library, I'll post next time
  14. 3 points
    The problem is not with CreateProcess[A] itself, but in how the output of the spawned process is [mis]interpreted by TRedirectedConsole when converted to a string format. What you describe is commonly known as "mojibake", and it can happen when 7/8-bit ANSI character data is mis-interpreted as 16/32-bit Unicode data, thus producing bad "characters" that fall within, in this case, the Chinese language, for instance. If you look at TRedirectedConsole's internal logic more carefully (specifically, in its ReadHandle() method), you will see that it reads the spawned process's output using the Win32 API ReadFile() function (which has no concept of string characters), stores the raw bytes as-is into a Char[] array, and then copies that array into a native String. That worked just fine in 2004 when Delphi's native String type was still AnsiString, and the native Char type was still AnsiChar. But remember that in Delphi 2009, the native String type was changed to UnicodeString, and the native Char type was changed to WideChar. As such, TRedirectedConsole's current reading logic is no longer valid under a Unicode environment. It needs to be updated to account for the fact that the 8-bit ANSI encoding of the spawned process's output is now different than the 16-bit Unicode encoding of Delphi's native String type. One way to handle this would be to tweak TRedirectedConsole to make it explicitly use AnsiString and AnsiChar everywhere, instead of using String and Char, respectively. This is commonly known as "Ansifying" your code, which is generally shunned upon, but this is a common use case for it. Also, note that AnsiString is now codepage-aware, so you would have to use the RTL's SetCodePage() function to assign a proper codepage identifier to any AnsiString you give to the user, so the ANSI data will be converted properly when assigned to other strings, such as a UnicodeString when adding to the TMemo (since the entire VCL uses UnicodeString now). Unless the spawned process is manipulating its output to use a specific encoding (like UTF-8), you can generally use the Win32 API GetACP() function for the codepage identifier, or the RTL's global DefaultSystemCodePage . For example: //============================================================== function TRedirectedConsole.ReadHandle(h: THandle; var s: AnsiString): integer; //============================================================== var BytesWaiting: DWORD; Buf: Array[1..BufSize] of AnsiChar; BytesRead: {$IFDEF VER100}Integer{$ELSE}DWORD{$ENDIF}; begin Result := 0; PeekNamedPipe(h, nil, 0, nil, @BytesWaiting, nil); if BytesWaiting > 0 then begin if BytesWaiting > BufSize then BytesWaiting := BufSize; ReadFile(h, Buf[1], BytesWaiting, BytesRead, nil); SetString(s, Buf, BytesRead); {$IFDEF CONDITIONALEXPRESSIONS} {$IF CompilerVersion >= 12} // D2009+ SetCodePage(PRawByteString(@s)^, GetACP(), False); {$IFEND} {$ENDIF} Result := BytesRead; end; end; ... //============================================================== procedure TRedirectedConsole.Run( working_dir : string ); //============================================================== var s: AnsiString; // not String! ... begin ... end; However, other areas of TRedirectedConsole would also have to be ansified, and I can see some issues with doing that, so I would suggest instead to have TRedirectedConsole continue to use the native String type everywhere, and just re-write the ReadHandle() method to explicitly convert the spawned process's output from ANSI to UTF-16, such as with the RTL's UnicodeFromLocaleChars() function (using the same codepage as above): {$IFDEF CONDITIONALEXPRESSIONS} {$IF CompilerVersion >= 12} {$DEFINE STRING_IS_UNICODESTRING} {$IFEND} {$ENDIF} //============================================================== function TRedirectedConsole.ReadHandle(h: THandle; var s: String): integer; //============================================================== var BytesWaiting: DWORD; Buf: Array[1..BufSize] of AnsiChar; BytesRead: {$IFDEF VER100}Integer{$ELSE}DWORD{$ENDIF}; begin Result := 0; if PeekNamedPipe(h, nil, 0, nil, @BytesWaiting, nil) then begin if BytesWaiting > 0 then begin if BytesWaiting > BufSize then BytesWaiting := BufSize; ReadFile(h, Buf[1], BytesWaiting, BytesRead, nil); {$IFDEF STRING_IS_UNICODESTRING} SetLength(s, UnicodeFromLocaleChars(GetACP(), 0, Buf, BytesRead, nil, 0)); UnicodeFromLocaleChars(GetACP(), 0, Buf, BytesRead, PChar(s), Length(s))); {$ELSE} SetString(s, Buf, BytesRead); {$IFEND} Result := BytesRead; end; end; end; //============================================================== procedure TRedirectedConsole.Run( working_dir : string ); //============================================================== var ... begin ... {$IFDEF UNICODE} // this is important to prevent a crash in CreateProcessW()... UniqueString(fCmdLine); {$ENDIF} // this raises an exception if anything happens Win32Check(CreateProcess(nil, PChar(fCmdLine), nil, nil, True, NORMAL_PRIORITY_CLASS, nil, wd, fSI, fPI)); ... end;
  15. 3 points
    Good reading on this subject: Are there any downsides to using UPX to compress a Windows executable?
  16. 3 points
    Well, now reality has arrived: https://www.heise.de/developer/meldung/Folge-der-Uebernahme-Idera-entlaesst-offenbar-viele-Travis-Mitarbeiter-4315673.html Or a taste of it in English: https://twitter.com/hashtag/TravisAlums?src=hash
  17. 3 points
    It uses "banker's rounding", after all. 😉
  18. 3 points
    WTF? Who stores ages as floating point and then uses arrays (which of course use integer indexing) for lookups? And this is a banking application? If this is typical code this whole thing is a rounding error waiting to happen and destroying the whole company. OK, to the actual problem: Add a check for the array bounds to the for loop: if Round(EntryAge) < LowBoundOfArray then raise exception.Create(...) if Round(RetireAge) > HighBoundOfArray then raise exception.Create(...) Where LowBoundOfArray and HighBoundOfArray are the minimum and maximum index values for the array. I don't remember if Delphi 5 already knew the Low(array) and High(array) functions. If it does, use these. My guess would be that a rounding problem causes access to elements ouside the valid array bounds and that causes your error.
  19. 3 points
    Impressive @RDPasqua! I can see a 8x speed up running a MARS "Hello World" project with 10K requests and a concurrency level of 100 (through Apache benchmark on localhost). It passes from 59.842 seconds to 7.617 (shrinking down total execution time to 12,7%). Of course my benchmark scenario can be improved (a Win10 VMWare Fusion machine, dual core over my MacBookPro late 2017, i7@3.5GHz). I made another test, querying a local Firebird (32bit) instance and performing a 'select * from EMPLOYEE' query with FireDAC to a (non-FireDAC) JSON serialization (about 10K bytes) and it passes from 33.640 seconds to 29.951 (shrinking down total execution time to 89%). So this time the gain is limited but still a good 10%. I am actually a bit puzzled how it's possible the first benchmark (textual 'Hello, World!') to be 200% slower than the second (returning a 42 records dataset JSON representation) but that has nothing to do with your memory manager replacement (although using RDPMM64 this does not happen anymore). I am attaching ab results for both scenarios. And on my MARS's to-do list now there's an entry to integrate Delphi-Cross-Socket as http server. 🙂 Congrats and keep up the good work! Andrea Benchmark_HelloWorld_DB_JSON_Response_Win64.txt Benchmark_HelloWorld_Text_Response_Win64.txt
  20. 3 points
    The development snapshot of IDE Fix Pack is actually compatible with the 10.3.1 update but because the WebInstaller loads the IDE Fix Pack DLLs into the installer the crash happens. Furthermore the WebInstaller deletes some registry keys and so partly uninstalls IDE Fix Pack. The next development snapshot will detect the WebInstaller and doesn't install the patches into it. It also tells the user to reinstall IDE Fix Pack after the update.
  21. 3 points
    Look into the thread about the annoucement. Somebody there posted a solution.
  22. 3 points
    Unfortunately not even good and reliable descriptions on how to reproduce the bug and even suggestions on how to fix them don't always get it fixed. I sometimes wonder whether they use some random number algorithm to select the bugs to be fixed.
  23. 3 points
    You SHOULD already be able to have per-project packages, in all versions of Delphi. The trick is to install the packages but NOT ENABLE them globally. With no project loaded, install the packages as needed, and then disable them so they don't appear in the Palettes when no project is loaded. Then, load a project, enable only the installed packages it actually needs, and close the project. Repeat as needed for other projects. Then, from now on, the IDE should load and unload packages on a per-project basis. At least, this is how it used to work years ago, I haven't tried it in recent years. Hopefully it still works.
  24. 3 points
    I know I go on about this but it's really important, in my view, to stress that the testing framework doesn't discover the bugs. It's the developer that writes good tests that discover the bugs. You need a testing framework to help manage the test code. But the strength of the test is always the quality of the test code rather than the framework. There are plenty of libraries that ostensibly have test suites but are full of bugs because the test suites are incomplete.
  25. 3 points
    @jbg thank you for the confirmation. I less and less understand Emb. This "new" IDE is so slow, flicker everywhere... Did they use their software? They should focus on quality rather than getting us such half backed solutions...
×