Lurker News
I think I've broken my own record with this one ~2500 lines of incoherent JavaScript/C#. Works though.

Comments (578) 119 threads

Show all comments

Showing thread 117 of 119

PavlovsCat4 replies#
My own CMS. Here's the function signature of the heart of it, which depending on circumstance may call itself recursively.

    function a_nodes_list_trees(
    	$site_url,
    	$base_url,
    	$mode,
    	$site_id,
    	$max_subtree_depth,
    	$nlevels,
    	$node_id = 0,
    	$tree_id = 0,
    	$nleft = 0,
    	$nright = 0,
    	$nlevel = 0,
    	$current_subtree_depth = 0,
    	$flags = 0,
    	$order = 'tree',
    	$inline = false, /* needed when loading stuff via ajax*/
    	$skipped_types = [],
    	$items_per_page = 10,
    	$min_tag_count = 2,
    	$min_author_count = 2,
    	$is_site_root = false,
    	$skip_pagination = false,
    	$ignore_404 = false,
    	$skip_display_options_and_batch_ops = false,
    	$display_bottom_pagination = true)
As you can tell from the default values, it started out having 6 arguments. And it has things like this in it:

    	$mysql_the_rest = 'FROM
    			'.DBTP.'node n
    				LEFT JOIN
    					'.DBTP.'node n2
    						ON
    							n.tree_id = n2.id
    						AND
    							n2.perm_view & ' . A_PERMS . '
    			'.$mysql_join.'
    		WHERE
    			'.$mysql_where2.'
    			'.$mysql_where.'
    			n.perm_view & ' . A_PERMS . '
    		AND
    			n.site_id = ' . $site_id . '
    		';
    	$total_count = $A->db->fetch_one_column('c', ' SELECT COUNT(*) c '.$mysql_the_rest);
.. you know? The whole CMS is 20k lines of PHP, with HTML, PHP, and MySQL all happily living together in the same files (it's not that I don't have templates, I just have plenty HTML in the PHP, too)

Yet, it works like a charm, PHP updates made it faster even, and I can use it for everything I needed so far, and use its output in a variety of ways. I still want to rewrite it, but it seems a lot of work to just shave off a few ms and have nicer code, with the same result for the visitor, and also having to write something that migrates the content. I suspect with enough content, it will slow down, and then I'll think about the next iteration. But it's still a mixture of pride, plain being happy to have it, and groaning whenever I fix a bug or add a feature.

abledon1 reply#
I feel your accounts bio perfectly matches the spirit of your posts content here haha!
PavlovsCat1 reply#
The quotes in my bio are by people who thought things through, while the CMS exploded in scope while I made it, so I'm not quite sure what you mean. Can you elaborate?
abledon1 reply#
The verbosity and wall of text
PavlovsCat1 reply#
Maybe, but at least it's more or less clear what I mean right away :P A million words conveying one unit of meaning are still more efficient than ten words conveying no meaning.

I just thought about that when I saw a youtube comment saying "stolen" in response to a funny joke. I wondered, do they mean they intend to "steal it" because it's a good joke, or did they mean the person who posted the joke stole it from somewhere? Nobody will ever know, at least I for one won't sign in just to ask.
I notice that since mobile devices, a lot of "communication" on the web these days is kinda like the "small talk" from Kevin from The Office US.
https://www.youtube.com/watch?v=_K-L9uhsBLM
If I hadn't asked what you meant, I and anyone else who read your comment would have had their own interpretation of it. I see a lot of comments like that on HN, where you would have to ask "what do you mean?" because it's totally unclear. A variation is stating something that is factually true but doesn't really refute anything, but the commenter clearly seems to mean something by stating that triviality, but don't say what it is. It's like dog whistles, but not for others to hear, but only the posters themselves know what they mean. Count me out.

Continue this thread — 1 reply

d0m1 reply#
An easy refactor for your function is to use a "Builder" for your params, i.e.:

options = NodeBuilder .author({ min: 2 }) .flag({ .. }) .pagitation({ .. })
function a_nodes_list_trees(options) { ... }
Because in the end, if your function is fast and working correctly, it's fine even though it's a little bit messy. The problem is more all the code calling this function and having to pass dozens of params in the right order, and then it's a pain to start adding/changing parameters. Also, when calling this function, you probably need a bunch of temporary variables to "build" all the params; all those temporary variables could instead live inside that builder object.

PavlovsCat#
I think I'll just use arrays, one for the caller, and one globally that has the default values. Fortunately that function isn't called in that many places.

Making and then really using the CMS helped me with knowing what I would want in my next CMS, and just keeping the whole in mind from the start would probably make it a lot better by itself. My thinking is that the longer I put that off, the more languages improved and the more I hopefully learned in the meantime ^^

pmarreck1 reply#
You're benefitting from an accurate mental model of this code (since you wrote it and work on it) and as soon as someone else has to work on this thing they are going to curse you.

So it might be job security but it's also vulnerable to the hit-by-a-bus problem

PavlovsCat#
When I started out, I wanted to opensource it, it had an installer and everything.. but then I realized it's become kind of a little monster and wisely canceled that plan, I'm not that irresponsible or mean :)
sonnyblarney1 reply#
My god man that is beautiful. I'm going to put that on a poster.