#STRING_SPLIT() function
Explore tagged Tumblr posts
magic-bad · 7 months ago
Text
Beware of Kitchen Sinks
The word "utility" sounds sophisticated. But what actually happens in practice is that people cannot come up with something more meaningful, so they just slap "util" onto their name, and declare victory. Resist this urge.
For example, suppose you come up with a nice string splitting function. You might think, "this can live in a library named string_utils". You might think that since the word "utility" fits, it is a good name. To illustrate the problem with this, allow me to slightly exaggerate: suppose instead of "utility", I decide to instead use "code" in the name. "code" fits, right? It is certainly true that what you did is code. And yet, nobody would use "string_code" as the name, because that would be vacuous. The same is true of "utils", albeit to a lesser degree. Think about which word is doing the real semantic heavy lifting. Is it "string" or "utils"? This is really another case of marklar.
Don't be creating a place that encourages everyone to dump all their random tangentially related things. What you have created is an abomination, similar to this:
Tumblr media
Here's what to do in this example: name the library string_split (or similar). You might be thinking, "A separate library JUST FOR SPLITTING?". Yes. Because bundling bad. The implementation of splitting does not involve joining (and vice versa). They can be separate, and therefore, they probably should be.
Another common "kitchen sink" word: "context". People use "context" when they do not want to name all the ingredients that are actually needed bake a cake. Implicit bad!
Explicit is better than implicit. --Zen of Python
Don't tell me that I need to supply a "fully stocked" kitchen in order for you to bake a cake. What if your last name happens to be Lindt, and as a result, you always had a giant pile of cocoa beans in your pantry when you were growing up. As a result, you do not consider a kitchen to be "fully stocked", unless there is a large supply of cocoa beans. Well, guess what, the rest of us are not named Mr. Lindt, ok?
The solution to your bad "fully stocked kitchen" recipe is simple: if you need cocoa beans to make a cake, just list cocoa beans as an ingredient. This is in fact how ALL recipes work. And algorithms are just data recipes. Nothing more; nothing less. Therefore, always list your ingredients (or the FDA will come after you!). Do not skip that job by saying, "oh you know. Just make sure to supply anything that any 'decent' kitchen would have.".
Now, if Jeeves the butler always does your grocery shopping for you (again, because your name is Lindt), and as a result, you don't know how grocery stores work, you can say, "Here, take Jeeves along with you. He knows what to buy.". Do not ask me to read Jeeves' mind. That's not a thing. It does not matter if I have 57 PhDs in computer science, I will never be able to read Jeeve's mind. Repeat after me: explicit good. Always be meaningful.
0 notes
sandeep2363 · 3 years ago
Text
STRING SPLIT function in MySQL or MariaDB
STRING SPLIT function in MySQL or MariaDB
STRING SPLIT function in MySQL or MariaDB To split the string MSSQL has an inbuild function STRING_SPLIT(string, separator). We try to create similar functionality in MySQL or MariaDB with the help of Procedure and a temporary table. MSSQL has a tabular function but MySQL or MariaDB does not. We created a procedure that will put the value into the temporary table. Create the following…
View On WordPress
0 notes