Jump to content
uniGUI Discussion Forums


uniGUI Subscriber
  • Content Count

  • Joined

  • Last visited

  • Days Won


elGringo last won the day on January 6

elGringo had the most liked content!

Community Reputation

45 Excellent

About elGringo

  • Rank
    Advanced Member

Recent Profile Visitors

603 profile views
  1. elGringo

    Are you more than 40 years old?

    Forever Young !) I'm coding on Delphi and enjoy it )))
  2. elGringo

    Delphi and Linux

    Hi, yes, Desktop Applications directly connected to a DB server. DB used local as usually.
  3. elGringo

    Are you more than 40 years old?

    Delphi forever young! UniGUI is the best!
  4. elGringo

    Delphi and Linux

    Hi, everyone. On my work, we have a lot of programs on Delphi. But ! Our government told that we have to move to national software to that is in registry of government to 2021 year. And in this registry only one operational system - Linux. So, we have 2 years to do smth. Could anyone give an advice what variants possible to not to change stack ? We have variant to move everything to .net core and react. So, is any way to solve this in Delphi way ? I found fmx linux framework, so could it be a decision ? Or maybe some server side on Delphi for Linux ? Is smth. interesting in UniGUI roadmap ?
  5. elGringo

    Disappointed with Unigui? There are alternatives coming!

    No! I use UniGUI in my projects. It looks like this is the best Web framework for Delphi. Hope Mr. Farshad will develop it to next years! Regards...
  6. elGringo

    Are you more than 40 years old?

    hi, the answer is )
  7. elGringo

    GarbageCollector class - what do you think?

    Thnks! Just thought there is the way that shows "SomeUnit, string 157, memoryLeak 120 Kb, TStringList" ))
  8. elGringo

    GarbageCollector class - what do you think?

    And what about this example? Wrapper for classes, based on ARC ? Looks smart ))) So, you may avoid try... finally... and just Create Use Forget ))) unit uSmartPointer; interface type ISmartPointer<T> = reference to function: T; TSmartPointer<T: class, constructor> = class(TInterfacedObject, ISmartPointer<T>) private FValue: T; function Invoke: T; procedure SetValue(const Value: T); public constructor Create; overload; constructor Create(AValue: T); overload; destructor Destroy; override; function Extract: T; property Value: T read FValue write SetValue; end; implementation constructor TSmartPointer<T>.Create; begin inherited Create; FValue := T.Create; end; constructor TSmartPointer<T>.Create(AValue: T); begin inherited Create; FValue := AValue; end; destructor TSmartPointer<T>.Destroy; begin FValue.Free; inherited; end; function TSmartPointer<T>.Invoke: T; begin Result := FValue; end; procedure TSmartPointer<T>.SetValue(const Value: T); begin FValue := Value; end; function TSmartPointer<T>.Extract: T; begin Result := FValue; FValue := nil; end; end. Example of use procedure Smart; var sl: ISmartPointer<TStringList>; begin sl := TSmartPointer<TStringList>.Create(); sl.Add('I am inside automanaged StringList'); end;
  9. elGringo

    GarbageCollector class - what do you think?

    and besides, my topic start code here gives 2 possibilities -manage code manually as usual, by grouping instances by tag -100 % clear on App Close if you have forgotten to clear smth inside the scope (protection from human factor...) Regards...
  10. elGringo

    GarbageCollector class - what do you think?

    Another alternative to the class i showed is ARC, but here we should know about weak, unsafe links and raw pointers I'm reading now book Delphi Memory Management for Classic and ARC Compilers...
  11. elGringo

    GarbageCollector class - what do you think?

    hm... agree with you, just it was start for discussion about the memory management in Delphi. So, could you say how do you look for memory leaks with fastMM - i don't know that for the moment. I use only ReportMemoryLeaksOnShutdown := true; But this approach only says me that there is a memory leak and what is leaking TStringList or etc... But how, for example you find memory leak in special exact place of code? Regards, Stan
  12. look at this class unit uGC; interface uses System.Generics.Collections, Rtti, System.Classes; type TGarbageCollector = class(TComponent) public const DEFAULT_TAG = 'DEFAULT_TAG'; private items: TDictionary<TObject, string>; public destructor Destroy; override; constructor Create(AOwner: TComponent); override; function Add<T>(item: T): T; overload; function Add<T>(item: T; const tag: string): T; overload; procedure Collect(const tag: string); end; var GC: TGarbageCollector; implementation uses System.Types, System.SysUtils; constructor TGarbageCollector.Create(AOwner: TComponent); begin inherited; items := TObjectDictionary<TObject, string>.Create([doOwnsKeys]); end; destructor TGarbageCollector.Destroy; begin items.free(); inherited Destroy; end; function TGarbageCollector.Add<T>(item: T): T; begin result := Add(item, DEFAULT_TAG); end; function TGarbageCollector.Add<T>(item: T; const tag: string): T; var obj: TObject; v: TValue; begin v := TValue.From<T>(item); if v.IsObject then begin items.add(v.AsObject, tag); result := item; end else raise Exception.Create('not an Object'); end; procedure TGarbageCollector.Collect(const tag: string); var key: TObject; item: TPair<TObject, string>; gcList: TList<TObject>; begin gcList := TList<TObject>.Create(); try for item in items do begin if (item.Value = tag) then gcList.add(item.Key); end; for key in gcList do items.remove(key); finally gcList.free(); end; end; end. Create it program GarbageCollector; uses Vcl.Forms, uMain in 'uMain.pas' {Main}, uGC in 'uGC.pas', uSomeClass in 'uSomeClass.pas'; {$R *.res} begin Application.Initialize; Application.MainFormOnTaskbar := True; GC := TGarbageCollector.Create(Application); // <<< Application.CreateForm(TMain, Main); Application.Run; end. use it someInstance := GC.Add(TSomeClass.Create(nil), 'TSomeClassTag'); // do smth with someInstance //now destroy GC.Collect('TSomeClassTag'); // anotherInstance := GC.Add(TSomeClass.Create(nil), 'TSomeClassTag'); // do smth with anotherInstance // not destroying here - will be destroyed on app destroy... what do you think?
  13. elGringo

    Are you more than 40 years old?

    Great ))) We can open museum here ))) But as for seriously, we could be any age, any technology stack, more important is the love of what you are doing and how. On any language we can do good and bad things, popularity will always be changable. Choose yours! When i started this topic, i tried to understand, should i continue with Delphi or switch to C#, as for now, i understand - both of them will always have their lovers) And i have projects on both as for now. Knowledge of different technologies enriches your skills as a programmer. For ex. i love mvc pattern from asp mvc and use it in my current projects, 'cause it gives clear transperent code... And of course, UniGUI, the best framework for Delphi and Farshad is the Genious of Delphi ))) Regards...
  14. elGringo

    MVC pattern in UniGUI vs traditional coding to form

    Unit testing quite easily maybe done with DUnitX. But "Clean Code" and "Readability" - it is from practice... Which code pattern to use is also good question...
  15. Asked myself - answered myself my workAround procedure TLeftMenu2.OnClickElement(Sender: TObject); function getLeftMenuElement(aID: integer): TLeftMenu2Element; var i: Integer; begin Result := nil; for i := 0 to FOL.Count - 1 do if FOL[i].Tag = aID then begin result := FOL[i]; break; end; end; var leftMenu2Element: TLeftMenu2Element; begin if (Sender is TUniLabel) then leftMenu2Element := getLeftMenuElement((Sender as TUniLabel).Tag); showmessage(leftMenu2Element.lName.Caption); end;