Recent

Author Topic: TBase64 Encoding-Decoding  (Read 27733 times)

eny

  • Hero Member
  • *****
  • Posts: 1658
Re: TBase64 Encoding-Decoding
« Reply #15 on: April 18, 2011, 12:05:58 pm »
I don't really see what this division gains. Sure, you can allocate an extra class around what is basically a single procedure, but what is the point?

It's called software abstraction and benefits would be that you get more robust, better maintainable, expandable and testable software (the software in this case would be the LCL itself).

You're right of course that 'other operations' might need other/more stream features. But that's a different 'family of problems' and may result in it's own abstraction. The key point here is that the base64 encoding/decoding now is tightly coupled with streams. Wheheas the encoding itself has nothing to do with streams.
Just my 2 cents  :)
All posts based on: Win11; Lazarus 4_4  (x64) 12-02-2026 (unless specified otherwise...)

Relative

  • Jr. Member
  • **
  • Posts: 56
  • Sedo est anima rerum.
    • FxCoder
Re: TBase64 Encoding-Decoding
« Reply #16 on: April 19, 2011, 10:00:41 am »
Code: Pascal  [Select][+][-]
  1.   function eC(s:PChar): PChar; stdcall;
  2.   begin
  3.     with TBase64EncodingStream.create(TStringStream.Create('')) do
  4.     try
  5.       SourceOwner := true;
  6.       write(s^,length(s));
  7.       result := PChar(TStringStream(Source).DataString)
  8.     finally
  9.       free;
  10.     end;
  11.   end;

I can't use it. The Source and SourceOwner identifiers aren't founded. After I assigned, them aren't initialized or used.

Sorry about my poor programming (and English) knowledge. I'm a beginner in FreePascal.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12715
  • FPC developer.
Re: TBase64 Encoding-Decoding
« Reply #17 on: April 19, 2011, 10:20:33 am »
I don't really see what this division gains. Sure, you can allocate an extra class around what is basically a single procedure, but what is the point?

It's called software abstraction and benefits would be that you get more robust, better maintainable, expandable and testable software (the software in this case would be the LCL itself).

I don't mean I want the general bla bla. I want to hear how that theory applies to this exact piece of code.

Quote
You're right of course that 'other operations' might need other/more stream features. But that's a different 'family of problems' and may result in it's own abstraction. The key point here is that the base64 encoding/decoding now is tightly coupled with streams. Wheheas the encoding itself has nothing to do with streams.
Just my 2 cents  :)

It assumes that all encoding works on full streams though. IMHO this is overspecialization.  I think the simple procedure that takes two strings is way more logical than this contraption.

eny

  • Hero Member
  • *****
  • Posts: 1658
Re: TBase64 Encoding-Decoding
« Reply #18 on: April 19, 2011, 10:03:34 pm »
I don't mean I want the general bla bla. I want to hear how that theory applies to this exact piece of code.
Apologies for sharing some thoughts.
It won't happen again.
All posts based on: Win11; Lazarus 4_4  (x64) 12-02-2026 (unless specified otherwise...)

 

TinyPortal © 2005-2018