Jump to content

Kas Ob.

  • Content Count

  • Joined

  • Last visited

  • Days Won


Kas Ob. last won the day on June 24

Kas Ob. had the most liked content!

Community Reputation

62 Excellent

1 Follower

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I want to remove or enhance the way code is written and used to be shorter and more flexible, interfaces are merely a marker for the target (end line) and they will never be the target them selves, while current interfaces implementation is serve one purpose and you can have the same code without them, so what did they brought to the table ? ( not starting long discussion but merely trying to explain my point) Reference counting, this should be against the one abstraction rule, they brought code limitation, so they (i mean in Delphi) already in grey area not like any other while not only abstraction, why stop there, why not make use of this syntax in code in something more helping like combine them with helpers, and this doesn't mean we are losing current interfaces usage. Talking about castles, if the target is to have a castle with some specifics, these specifics or requirements will never list every things or how every detail should be, many is up to you to build and change as you see fit, after all building a castle might take months, now in case to be prepared of war i want to make a bridges in air between towers, this against all castle towers rules in the world but will serve the defenders greatly, can i do it ? or the interface and foundation will prevent me, and how is it hard to build/adjust if the foundation need a small adjustment. Can foundations serve as tunnels ? or water storage ? or they only must be mute pile of stones and concrete ? That well as object can be used in different project lets say building a farm, but here the object is the well ( aka water source) and the interface is just junk lines server nothing and almost always it will be a "castle-well", i prefer to bring the well as object and add when/if needed an interface for it per project not the way around, because the target is the farm here. I am not sure how different i design things, but once a class had an interface almost 75% guarantee that class is belongs to one project realm and reusing it is limited in different project, interfaces in my opinion kills the portability and fatten the code uselessly, and most importantly when the building process is started which might be long time modifying the interface is slow process, i know i can put one class and object in one unit file, but this is ugly, i use interfaces only for the castle itself unless i see greater benefit for other internals but never for the halls, stables, walls, wells ... the stuff inside. The discussion of interfaces and their usages is long and i don't see this is the case, simply put helpers are more efficient and more useful than interfaces (and faster), relaxing the interfaces where one can derive the interface itself from the "logic of the object" can be useful (of course in some cases) mixing helpers and interfaces might yield even more profits and save time (also in some cases), when i design the limit for my imagination is the sky and should not be the interface, for what it worth the greatest ideas comes while building not while designing, we as all developers might miss an idea when designing and struck gold while building, and having the design (blueprint) carved on metal or stone one might ditch it for the sake of saving time.
  2. I have few ideas that might worth discussing like this one that will belongs to Language or Compiler, yet to be seen. Different variable declaration, something new like mvar (managed) or svar (safe), to be used like this procedure LoadComaSeparated(const aFileName: string); var C: Integer; mvar // managed and intialized varaibles, that will initialized to default,eg. integer = 0 , boolean to false etc StrList: TStringList; // this will be created automatically and compiler hide the create try..finally free // as long the contructor had default parameters or no parameters at all, just like local string begin StrList.LineBreak := ','; StrList.LoadFromFile(aFileName); end; How nice is that ?, with no compatibility issue with anything written with Delphi, also it is easy to implement.
  3. If just cool water killed the bugs ! instead of compiler drooling mixed with my coffee,.. took me long time to stop punching the monitor and take on habit of splashing coffee on it, it does yield better effect, try it in the evening for best result. I would suggest three separated threads, RTL, Compiler and Language itself ( thinking in loud voice a decision about naming will need an overhead of 5-7 threads and... we are OK) Each thread will will have its own scope ( like compiler stuff belongs to compiler thread but it might be mentioned as reference in other posts), discussion is about requests, features and something you like to see, ideas in general is OK too, with of course listing the advantages, one feature per post to make it easy to divide and conquer ( i mean give it deep and well deserved think time), such threads can be helpful understand Delphi itself while serve as historical reference when Embarcadero guys feel bored and looking for ideas, or someone submit it while having them discussed here might have high vote rate.
  4. One thing though, the point of having syntax in a language is to make written in a stone or let it evolve to something better, shorter, may be just more productive. The way interfaces is declared and used in current state is hindering there usage and somehow counter productive (i know what they serve) , so if you are writing a layer of lets say file management (many classes and unit files), then most likely you will prefer to expose only the outer interface of that layer in whole, but internally that file handling layer really should not have interfaces, this will just waste of time specially in adding features later and will be prone to errors and just huge waste of time, like where interfaces doesn't have inheritance, so more interfaces are needed. Yes, i understand the importance and usefulness of abstraction, but can an abstracted layer used in its own code to serve multi purposes ? Can the outer interface be minimized to be extracted from a class, instead of be forced to build upon it, just different way of thinking, and one might take in either way, i just love to have more choices, a with shorter and clearer code where i allow change in one place instead of two. Look at that example, the logger it might had nothing to do with objects and yet it can have all access if one want it, it is simply an idea to evolve, after how this is far away from how generics came to a language, if you go back and look at the past and see the same logic goes like here, a class is declared as...., and in generics a type is declared ... contradicting class declaration ( it is not a contradiction now) , try to imagine the discussion about generics when they started as an idea, i am sure many said it is good but al so many said it is wrong and will bring only errors, so this can go either way. It was an idea, simply put, just food for thought in a thread i think can be very useful as think tank to discuss evolution of interface, if that will ever happen.
  5. Here another idea, and it is not about helpers for interfaces, but to a cross between them. Interfaces are limited, and hindering the way you declare objects (that is the point after all) , means compiler should have the interface first then the Object/Class declaration. Helpers are more relaxed, but yet you should have the Object/Class first then the helper, and that will be guaranteed by the compiler, and only one with ancestor, also scope is playing role here. So, what about something hybrid like this type ILogger = interface //(IInterface) helper function CreationTime: TDateTime; helper procedure LogSelf; procedure SomeExtraLogging; end; { ILogger } helper function ILogger.CreationTime: TDateTime; begin Result := FCreationTime; // will behave like helper does, FCreationTime should be a field in the object end; helper procedure ILogger.LogSelf; begin DoLog(Self, CreationTime); // Self here belongs to the Object/Class, and yet CreationTime is still accessible end; With helper functions/procedures the interface will still behave like always it did, but when it comes to helper methods they will be resolved at compile time to handled as helper per Class, means all what compiler have to do is to delay the helpers methods until the interface been used in an object Advantages: 1) No backward compatibility is broken, no change to existing code or the old style. 2) Helpers with such declaration will be even more helpful, as you can now use multiple from any scope (close or far). 3) Shorter code in Objects/Class, means less complexity and more clarity, the compiler will fail to compile when interface helper method been used and doesn't belongs to according Object, it should fail on the object not the interface, same as failing to compile object without according interface method, and same as it will fail of a helper tried to access non existed fields/method.
  6. That is interesting, the manual insist on mentioning TLS, and it might be in generic meaning as Transport Security Layer, because looking at your log file, the first packet has 19 byte size and this can't be a ClientHello message record for TLS, as at least a random with 32 byte should be included ! So here 2 points to check 1) That module doesn't have TLS, mean it will use pre shared key for direct encryption/decryption using the algorithms mentioned in the documentation But here i have difficulty understanding the lack of mentioning of what padding is been used, combine this with the fact first packet was 19 bytes, on other hand this might work if the size of the packet is defined and fixed as 3+n*16 which will start to make sense, but you first need to capture one packet ( the first one with 19 bytes ) and paste it here to see what is inside, will be better if you repeated it and confirmed it is still the same, then change the key on that module ( only the key not the algorithm) and capture another packet to compare them, and do the same for second algorithm 3DES, is there a third option in that security box in Sock group, AES , 3DES .. ?? (TLS may be, if not then TLS is not supported on that module) 2) the module does support TLS somehow, but in this case it will be using the PSK cipher suites, i looked at ICS source and i see that the default is all PSK ciphers are disabled, here Angus can help if that is possible to enable them and how, i have no idea. the ciphers that might be working should be some of those, (all of these doesn't need certificates) // likely to work 0x00,0x8B TLS_PSK_WITH_3DES_EDE_CBC_SHA Y N [RFC4279] 0x00,0x8C TLS_PSK_WITH_AES_128_CBC_SHA Y N [RFC4279] // very unlikely to be supported 0x00,0x90 TLS_DHE_PSK_WITH_AES_128_CBC_SHA Y N [RFC4279] 0x00,0x94 TLS_RSA_PSK_WITH_AES_128_CBC_SHA Y N [RFC4279] 0x00,0xAE TLS_PSK_WITH_AES_128_CBC_SHA256 Y N [RFC5487] 0x00,0xB2 TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 Y N [RFC5487] 0x00,0xB6 TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 Y N [RFC5487] 0xC0,0x35 TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA Y N [RFC5489] 0xC0,0x37 TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 Y N [RFC5489] cipher lists from here https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml Anyway if first case is how it does data been sent then your server doesn't need OpenSSL at all, the second will will need a confirmation from Agnus on how to test it.
  7. My 2 cents: 1) Which module is it ? and what is the specification regarding supported protocols ( TLS version and cipher suites ) Are you going to connect to it as client or it will connect to you as server ? 2) You mentioned this twice, and yet it is still not clear, the modules in that links are IOT devices and those devices usually doesn't use the popular cipher suites with certificates because it does complicate things greatly for the trust anchors (chains), most IOT devices use (Pre-Shared Keys) PSK cipher suites and those doesn't need certificate, like your WiFi on android, and there is another less popular cipher suites called SRP that use passwords instead of PSK, so are those available ? 3) can you generate a WireShark log for the ClientHello and ServerHello for the failed connection? this will help much and reduce the time needed for pinning the problem, or in your case finding solution, as this is not bug .
  8. Kas Ob.

    Regex Validate string

    @Mahdi Safsafi Thank you, i didn't know that. It was one line to filter out every other Unicode, and will be interesting to see how RegEX handle numbers (Hindu and Arabic), later will investigate.
  9. Kas Ob.

    MMX 15.0.18 - font bug

    I don't think it worth your time, but out of thousands of time i double clicked a method to edit or sometime just to look at how beautiful the Edit Method window, once or two i noticed that the visibility been wrongly set to default, but one in thousands chance.
  10. Such creature can be called FreeNullator or FreeNilator
  11. May be the case, on other hand, changing ( or forcing it to be inlined) with little smart on compiler side, it can be used even with strings !, like for strings set its length to 0, with memory pointers call FreeMemory on it and so on.. But as you said it is doubtful to see such thing.
  12. Kas Ob.

    Regex Validate string

    Don't validate per char as it will be maze to follow in Unicode, and don't use RegEX as it will be different problem as numbers settings in the OS might be Arabic (those numbers in fact Hindu mistakenly called Arabic) for all Locale and they will cause havoc. I do it differently, i also wrote a filter to filter out any non English and non Arabic chars TEncoding.GetEncoding(1256).GetString(TEncoding.GetEncoding(1256).GetBytes(aText)) any other languages chars will be '?', many special chars will be '?' , special chars wasn't not a problem in my case, it was requested to prevent bad (offending) words that is written in different languages and the administrators don't understand them. I don't use TEncoding but windows API directly, but i think you got the idea.
  13. Or the idea initially was to have FreeAndNil for Objects and Memory Pointers, but the overloaded versions were dropped because the confusion they caused.
  14. Kas Ob.

    Ctrl Tab Ide Plugin

    It is doable and easy. type TColorScheme = record PathColor: TColor; FileNameColor: TColor; SelectedBG: TColor; end; const COLOR_SCHEMES : array [0..1] of TColorScheme =( (PathColor : $003853EB; FileNameColor : $000E5F3D; SelectedBG : $00EEE1D0), (PathColor : clGrayText; FileNameColor : clBlack; SelectedBG : clSilver)); procedure DrawColoredFileName(aCanvas: TCanvas; aRect: TRect; const aFileName: string; aColorScheme: integer = 0); var LPath, LFileName: string; LPathPxLen, LFNamePxLen: Integer; LFNameX: Integer; begin LFileName := ExtractFileName(aFileName); LPath := ExtractFilePath(aFileName); // get Path Length in Pixles LPathPxLen := aCanvas.TextExtent(LPath).cx; LFNamePxLen := aCanvas.TextExtent(LFileName).cx; // Draw Path aCanvas.Font.Style := []; aCanvas.Font.Color := COLOR_SCHEMES[aColorScheme].PathColor; aCanvas.TextOut(0, aRect.Top, LPath); // Draw FileName aCanvas.Font.Style := [fsBold]; aCanvas.Font.Color := COLOR_SCHEMES[aColorScheme].FileNameColor; // over draw long path instead of hiding file name if LPathPxLen + LFNamePxLen > aRect.Right - aRect.Left then LFNameX := aRect.Right - LFNamePxLen else LFNameX := LPathPxLen + 2; // 2 pixel margin, can be constant too aCanvas.TextOut(LFNameX, aRect.Top, LFileName); end; procedure TForm10.CheckBox1Click(Sender: TObject); begin ListBox1.Invalidate; end; procedure TForm10.ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); var ListBox: TListBox absolute Control; begin if odSelected in State then ListBox.Canvas.Brush.Color := COLOR_SCHEMES[Ord(CheckBox1.Checked)].SelectedBG else ListBox.Canvas.Brush.Color := clWhite; ListBox.Canvas.FillRect(Rect); if (Index > -1) and (ListBox.Items.Count > Index) then begin DrawColoredFileName(ListBox.Canvas, Rect, ListBox.Items.Strings[Index], Ord(CheckBox1.Checked)); end; end; This just an example on how to do it, hope you like it, and remember to put Style of the listbox to OwnerDraw Two things though: 1) That code doesn't handle the different states, selected, grayed, focused...etc, this is up to you to do and learn. 2) No DPI scaling fixing or handling, for that i think we both ( you and me) need someone to explain on how to do it right, on Windows 10 and older versions. Away from that, i really suggest to start with this example ( others may suggest better approach), but that is not the point, the point is after you do this, you will have way better understanding how VCL does drawing in general and its capabilities, it will be useful experience and knowledge to have. the result of that code is like this
  15. Kas Ob.

    Possible custom Format types?

    Not an answer to your question, but a suggestion Change the function to return boolean if such invalid characters detected, and the result string (sanitized) will return in var parameter, such you will be able to show and log the original invalid string, yet still can silently discard it and use the fixed one.