123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- <?xml version="1.0" encoding="utf-8"?>
- <!--
-
- h t t :: / / t /
- h t t :: // // t //
- h ttttt ttttt ppppp sssss // // y y sssss ttttt //
- hhhh t t p p s // // y y s t //
- h hh t t ppppp sssss // // yyyyy sssss t //
- h h t t p s :: / / y .. s t .. /
- h h t t p sssss :: / / yyyyy .. sssss t .. /
-
- <https://y.st./>
- Copyright © 2016 Alex Yst <mailto:copyright@y.st>
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org./licenses/>.
- -->
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <base href="https://y.st./en/weblog/2016/11-November/06.xhtml" />
- <title>When developers mark a property (or method) as private, they do so for a reason! <https://y.st./en/weblog/2016/11-November/06.xhtml></title>
- <link rel="icon" type="image/png" href="/link/CC_BY-SA_4.0/y.st./icon.png" />
- <link rel="stylesheet" type="text/css" href="/link/basic.css" />
- <link rel="stylesheet" type="text/css" href="/link/site-specific.css" />
- <script type="text/javascript" src="/script/javascript.js" />
- <meta name="viewport" content="width=device-width" />
- </head>
- <body>
- <nav>
- <p>
- <a href="/en/">Home</a> |
- <a href="/en/a/about.xhtml">About</a> |
- <a href="/en/a/contact.xhtml">Contact</a> |
- <a href="/a/canary.txt">Canary</a> |
- <a href="/en/URI_research/"><abbr title="Uniform Resource Identifier">URI</abbr> research</a> |
- <a href="/en/opinion/">Opinions</a> |
- <a href="/en/coursework/">Coursework</a> |
- <a href="/en/law/">Law</a> |
- <a href="/en/a/links.xhtml">Links</a> |
- <a href="/en/weblog/2016/11-November/06.xhtml.asc">{this page}.asc</a>
- </p>
- <hr/>
- <p>
- Weblog index:
- <a href="/en/weblog/"><abbr title="American Standard Code for Information Interchange">ASCII</abbr> calendars</a> |
- <a href="/en/weblog/index_ol_ascending.xhtml">Ascending list</a> |
- <a href="/en/weblog/index_ol_descending.xhtml">Descending list</a>
- </p>
- <hr/>
- <p>
- Jump to entry:
- <a href="/en/weblog/2015/03-March/07.xhtml"><<First</a>
- <a rel="prev" href="/en/weblog/2016/11-November/05.xhtml"><Previous</a>
- <a rel="next" href="/en/weblog/2016/11-November/07.xhtml">Next></a>
- <a href="/en/weblog/latest.xhtml">Latest>></a>
- </p>
- <hr/>
- </nav>
- <header>
- <h1>When developers mark a property (or method) as <code>private</code>, they do so for a reason!</h1>
- <p>Day 00610: Sunday, 2016 November 06</p>
- </header>
- <img src="/img/CC_BY-SA_4.0/y.st./weblog/2016/11/06.jpg" alt="Tom and my mother" class="weblog-header-image" width="811" height="480" />
- <p>
- Current countdowns:
- </p>
- <ul>
- <li>234 scheme-specific <abbr title="Uniform Resource Identifier">URI</abbr>-parsing classes to write and add to <a href="https://git.vola7ileiax4ueow.onion/y.st./include.d/releases">include.d</a></li>
- <li>1 free elective left in my associate degree program</li>
- <li>4 free electives left in my bachelor degree program</li>
- </ul>
- <p>
- Topics for essays that I want to write outside of school:
- </p>
- <ul>
- <li>How the <abbr title="GNU "Free" Documentation License">GFDL</abbr> isn't a free license, and is effectively nonfree even when invariant sections aren't used</li>
- <li>How the telephone number system is screwy</li>
- <li>How postpaid mobile plans are bad for customers</li>
- <li>How connections using "untrusted" <abbr title="Transport Layer Security">TLS</abbr> certificates are more trustworthy than connections without any <abbr title="Transport Layer Security">TLS</abbr> certificate at all</li>
- <li>The importance of free software</li>
- <li>The importance of free media</li>
- </ul>
- <p>
- I modified my base 32 exception code encoder to use standard base 32 instead of my custom character set.
- This meant removing all non-letter characters and replacing them with a partial set of digits.
- Originally, I used various non-alphanumeric symbols because I felt (and still do feel) that a partial set of digits isn't very useful.
- A <strong>*full*</strong> set of digits would come in handy, but having several digits missing makes all the remaining digits less useful.
- However, standards are important, so I've cleaned up my code.
- For a bit, I again contemplated using 64-bit exception codes instead of my current 32-bit codes.
- With 64-bit exception codes, I could have full Unicode support with 8-byte codes.
- I'd have characters in the <abbr title="American Standard Code for Information Interchange">ASCII</abbr> range, or less characters when using multi-byte Unicode code points.
- That said, exception codes are stored as integers.
- <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> integer size is platform-dependent, and <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> doesn't support 64-bit integers on 32-bit platforms.
- I'm on a 64-bit system, but other users of my code might not always be.
- With only 32 bits, having a decent character set has to be weighed against having a decent string length.
- The larger the character set used, the shorter the string encoded has to be.
- The best options that I can come up with are strings made up of five six-bit characters or six five-bit characters.
- Something in between is possible, but too difficult to work with to be worth it.
- Originally, I actually tried to get something in the middle, but the encoding and decoding was taking a lot of code, didn't seem easy to maintain, and was difficult to get right.
- I ended up scrapping that idea in favor of using whole numbers of bits for each encoded character.
- Both five-character strings made up of six-bit characters and six-character strings made up of five-bit characters use up only thirty bits, leaving (on 32-bit systems) two bits left over.
- I ended up using one bit as a flag, toggling between five-bit character mode and six-bit character mode, so either can be used whenever most useful.
- Not only does this offer more options, it makes usable half of the 32-bit integer range that would otherwise remain untouched.
- I use the other spare bit as a flag to divide the exception code space in half, using half for reusable code and half for single-project code.
- If I was working with 64-bit integers, I'd lose both of these flags, but one would be useless anyway and the other would be easy to live without.
- I considered setting up a method of providing a 32-bit exception code for 32-bit platforms and a 64-bit exception code for 64-bit platforms, passing both codes into the exception constructor and allowing the constructor to figure out which to use based on the platform, but it seemed to be too difficult to maintain.
- I'd need a list of all exception codes for both integer sizes, making sure that both lists didn't contain duplicates.
- Having a single list takes half the effort to maintain while not really providing much less value.
- </p>
- <p>
- I took a look at the <code>cid:</code> and <code>mid:</code> scheme's scheme-specific syntax, but I've decided to put off building classes for those schemes just yet.
- The syntax is a bit complicated due to the fact that the <abbr title="Uniform Resource Identifier">URI</abbr>s use <abbr title="Uniform Resource Identifier">URI</abbr>-encoded versions of data that fits an entirely-different syntax.
- Validating data would require validation rules based on what the data decodes to.
- Come to think of it, as I write this, it becomes obvious what the correct way to do this is.
- I must decode the data, then validate it.
- That would be <strong>*so*</strong> much easier than attempting to validate the encoded version.
- I might work on that tomorrow.
- I also completed work on the <code>coaps:</code>- and <code>coap:</code>-scheme classes, but those were on the other end of the effort spectrum.
- They took almost no work to set up.
- </p>
- <p>
- After setting up a couple of simple scheme classes, I build some code that counts how many schemes I've finished with and home many more I have left to complete.
- I'm tired of trying to track that myself, having to remember which new scheme classes I've accounted for yet and which I haven't.
- I also built an exception code tracker and documenter into my debug scripts so I can just add exceptions wherever I need them and not worry about taking notes.
- </p>
- <p>
- I had a flash of inspiration on how to build the function that I was working on about five months ago that tries to figure out which library files are used by a given script.
- The purpose of this was to make it easy to include only part of include.d within a project instead of putting include.d as a whole in the <code>include_path</code> and allowing all projects to access its features.
- While this isn't the preferred way of using include.d, it might be useful to developers that don't want to rely on external dependencies.
- Previously, I was tokenizing the contents of scripts and trying to make inferences based on certain tokens that weren't even directly related to the information that I was looking for.
- This time, however, started out with instead using a custom autoloder for classes and a custom function for <code>require()</code>ing function and constant files.
- These two functions could record the files that they import, then report them once the script terminated.
- By actually running the script, I'd get all the information that I needed about what library files were actually used! The main issue with this is that branched script flow and varied input might result in some classes only sometimes being used and therefore potentially not finding their way onto the list of files used in a given run.
- The other issue is that while the custom autoloader would be easy to replace with one line change, the function for loading functions and constants would be used many times, so it might be better to have that function act differently depending on some sort of flag.
- Then again, because functions and constants need to be manually included, it's probably best to simply include them from the top of the main script.
- Reading a list of needed files from there would be no problem when trying to figure out which parts of include.d to use.
- In any case though, I came up with a better idea, using information that <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> itself already has.
- I remembered that <a href="https://secure.php.net./manual/en/function.get-defined-constants.php"><code>\get_defined_constants()</code></a> not only reports what constants have been defined, but can sort user-defined constants from language-defined constants.
- Was the same functionality available for classes and functions? Maybe not.
- There's a <a href="https://secure.php.net./manual/en/function.get-defined-functions.php"><code>\get_defined_functions()</code></a> function and a <a href="https://secure.php.net./manual/en/function.get-declared-classes.php"><code>\get_defined_classes()</code></a> function, but neither is able to sort user-defined constructs from system-defined constructs.
- (It's worth noting that <code>\get_defined_classes()</code> won't return all classes, and <a href="https://secure.php.net./manual/en/function.get-declared-interfaces.php"><code>\get_defined_interfaces()</code></a> and <a href="https://secure.php.net./manual/en/function.get-declared-traits.php"><code>\get_defined_traits()</code></a> are needed to get the rest.) I started looking into a way to tell if a given function or class is user-defined or language-defined, figuring that I could simply iterate over the output of the get_defined_*() functions, but instead of answers to that, I found something shocking.
- </p>
- <p>
- As it turns out, <a href="https://ocramius.github.io./blog/accessing-private-php-class-members-without-reflection/">private structures such as private object properties aren't really private</a>.
- Using <a href="https://secure.php.net./manual/en/closure.bindto.php"><code>\Closure::bindTo()</code></a>, functions can be injected into <abbr title="application programming interface">API</abbr>s that they don't belong in, allowing access to private areas.
- I don't mind allowing read access, but this allows write access to.
- It undermines the concept of private properties and methods in every way.
- All of the data-validation checks that I've been writing into my <abbr title="Uniform Resource Identifier">URI</abbr>-processing <abbr title="application programming interface">API</abbr> are for nothing, and that's just the example that affects me personally.
- Defining a class is like defining a new data type.
- The class is able to insure that certain rules are followed so that the data fits into the appropriate data domain.
- When validity checks are undermined, the class is no longer able to insure that instance objects will behave as intended.
- Type hinting in function and method declarations no longer have their full meaning.
- These functions and methods expect well-behaved objects, but that's not what they're guaranteed to get any more.
- Likewise, the <code>instanceof</code> key word is no longer able to properly check an object for its behavior.
- I did a little experiment to see if the problem's impact was what I thought it was, and indeed, it is that bad.
- Using this closure method, I was able to unset the scheme of a <abbr title="Uniform Resource Identifier">URI</abbr> object, a feat that I'd programmed to be impossible, due to the fact that all <abbr title="Uniform Resource Identifier">URI</abbr>s are required to have a scheme.
- This broke the <code>\st\y\uri::__tostring()</code> method, causing it to spit out errors instead of returning the string representation of the <abbr title="Uniform Resource Identifier">URI</abbr>.
- When developers mark a property (or method) as <code>private</code>, they do so for a reason!
- </p>
- <p>
- I still only have one work uniform.
- Washing one day's worth of clothing is far too expensive at a laundromat, so I just decided to start washing my work uniform by hand in the bath tub.
- It's not the most elegant solution, but it'll have to do for now.
- </p>
- <p>
- It seems that my mother somehow decided that I wanted to visit a <a href="https://en.wikipedia.org./wiki/Bird_of_prey">raptor</a> center.
- I have no idea where they got this idea.
- I remember that years ago, my mother gave me an invitation and a flier for a raptor center, but I ignored it because my mother's always been very bad at gift-giving.
- At that time, I thought htat visiting a bunch of caged birds was a boring way to spend the day.
- Now, in addition to finding it boring, I feel that it's decidedly non-vegan and going is a horrid waste of fossil fuels.
- There is just nothing appealing about this prospect.
- My mother insists that at some point, I expressed an interest in this, but I'm not sure why I would do that.
- My best guess is that my mother's memory is failing them again and that someone else was the one to express such an interest.
- Either that, or my mother vastly misinterpreted what I had said.
- After all, my mother did think that I somehow wanted a creepy pedometer that sends heart rate and step counts to a company's server and requires a proprietary operating system to use, despite the fact that I repeatedly told them that I didn't want one.
- I tried not to be negative about the fact that they were using one, but every time that they brought up the idea of <strong>*me*</strong> using one, I always declined.
- </p>
- <p>
- A chunk of the day was used moving things to the storage unit, as well as removing things from the unit that my moter wants in their classroom.
- Some of it is stuff that I legitimately think tat they want there, but some of it is being moved to the classroom just to get it out of the way.
- It's teaching-related stuff, but not stuff that they'd have otherwise been interested in using this school year.
- </p>
- <p>
- Having concluded our work for the day, we went to visit a friend of my mother.
- My mother's friend Tom has a crush on them, which my mother isn't thrilled with.
- Tom won't accept the fact that my mother isn't interested, so my mother doesn't like to be alone with them.
- That's why I was there.
- We spent some time talking, then went home.
- </p>
- <p>
- My mother started cooking up some potatoes for their own dinner tonight and their breakfast tomorrow, but just as I walked into the room, the pan fell to the floor and it all went to waste.
- At first, my mother thought that I'd bumped it, but I wasn't anywhere near it yet; I was too far away to even catch it as it fell, though I did try.
- It was highly frustrating though.
- They were too tired to cook it again from the start.
- My mother doesn't cook very often, then the one time that they <strong>*did*</strong> cook, they didn't even get to enjoy their meal.
- </p>
- <p>
- Today was the final day of late course registrations.
- My options still hadn't opened up, so I was still unable to sort out my course situation.
- If the school staff were already planning to step in because of some Yst-is-a-newbie thing, everything might still be on track.
- Maybe they set their system to treat all new students this way because of poor programming on the part of their website developers.
- Hopefully I'll end up in the correct courses by Wednesday, when my next term starts.
- I can't help but feel that a particular assignment in <span title="Online Education Strategies">UNIV 1001</span> might be relevant.
- We were required to tell which courses we planned to take next term and explain our choices.
- What if this assignment was really a way to find out what courses to manually put us in next term?
- </p>
- <p>
- Google decided to throw a fit about my account again.
- This time though, they allowed my to unlock it using any <abbr title="Short Message Service">SMS</abbr>- or voice-enabled telephone number.
- This is just sheer lunacy.
- I borrowed Vanessa's mobile for that, but what was even the point from Google's perspective? They didn't require me to use a number that was associated with my account, which means that this was <strong>*in no way*</strong> a attempt at a security measure.
- Google was just being a pain as always for no good reason.
- Once I'm done with schooling, have found a reasonably-paying job, and moved out on my own, I can be done with Google forever.
- I only need this Google account so that I can use Google Voice to get a stable <abbr title="Short Message Service">SMS</abbr>-compatible telephone number for my mother to reach me at because my mother won't use basic email to reach me and can't stand that my number frequently changes when I change mobile plans.
- When I move out, my mother can either reach me via email like everyone else of they can choose some other non-telephone method of contact.
- </p>
- <p>
- My <a href="/a/canary.txt">canary</a> still sings the tune of freedom and transparency.
- </p>
- <hr/>
- <p>
- Copyright © 2016 Alex Yst;
- You may modify and/or redistribute this document under the terms of the <a rel="license" href="/license/gpl-3.0-standalone.xhtml"><abbr title="GNU's Not Unix">GNU</abbr> <abbr title="General Public License version Three or later">GPLv3+</abbr></a>.
- If for some reason you would prefer to modify and/or distribute this document under other free copyleft terms, please ask me via email.
- My address is in the source comments near the top of this document.
- This license also applies to embedded content such as images.
- For more information on that, see <a href="/en/a/licensing.xhtml">licensing</a>.
- </p>
- <p>
- <abbr title="World Wide Web Consortium">W3C</abbr> standards are important.
- This document conforms to the <a href="https://validator.w3.org./nu/?doc=https%3A%2F%2Fy.st.%2Fen%2Fweblog%2F2016%2F11-November%2F06.xhtml"><abbr title="Extensible Hypertext Markup Language">XHTML</abbr> 5.1</a> specification and uses style sheets that conform to the <a href="http://jigsaw.w3.org./css-validator/validator?uri=https%3A%2F%2Fy.st.%2Fen%2Fweblog%2F2016%2F11-November%2F06.xhtml"><abbr title="Cascading Style Sheets">CSS</abbr>3</a> specification.
- </p>
- </body>
- </html>
|