Closed (fixed)
Project:
Version Control API
Version:
6.x-2.x-dev
Component:
Documentation
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
18 May 2009 at 02:19 UTC
Updated:
3 Jan 2014 at 00:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
marvil07 commentedstill not finished(until now, I have added methods from funcitons from: versioncontrol-backend.inc, versioncontrol.admin.inc and versioncontrol.module), but here what I got now:
- maybe we want to remove "versioncontrol_" prefix on each class methods
- maybe VersionControlAPI class must be only a normal inc file
- about dia class diagram: underline is static, italics on class names means abstract, + means public, - means private, # means protected (see the classes tarball for an autocode if you prefer)
functions outside classes:
- all file:
- versioncontrol.admin.inc
left on versioncontrol.module(implementation of drupal api functions and own hooks):
- versioncontrol_init ()
- versioncontrol_theme ()
- versioncontrol_user ($type, &$edit, &$user, $category=NULL)
- versioncontrol_menu ()
- versioncontrol_admin_access ($account=NULL)
- versioncontrol_user_access ($account=NULL)
- versioncontrol_private_account_access ($vcs_accounts, $account=NULL)
- versioncontrol_versioncontrol_authorization_methods
- _versioncontrol_get_fallback_authorization_method
- _versioncontrol_construct_repository_constraints
- _versioncontrol_amend_repositories
- versioncontrol_versioncontrol_operation_constraint_info
- versioncontrol_versioncontrol_operation_constraints_alter
- theme_versioncontrol_account_username ($uid, $username, $repository, $prefer_drupal_username=TRUE, $format= 'html')
- theme_versioncontrol_user_statistics
- versioncontrol_block
- versioncontrol_user_autocomplete
- _versioncontrol_get_string_presets ()
loose some sense in OOP:
- versioncontrol_is_file_item() and versioncontrol_is_directory_item() loose sense if we have item and directory clasess, but not yet decided
not really sure where should go:
- versioncontrol_user_accounts_title_callback(), looks like a helper for profile tabs, so should it be left on *.module file
Comment #2
jpetso commentedNice, now we've got a basis for further discussion :)
Definitely, and in addition to that, we also want camel-case naming for methods, and remove the "entity" name from the function. (e.g. VersionControlRepository::load(), VersionControlOperation::getItems(), etc.) The DBTNG API in core uses this kind of naming - which is derived from official PHP standards anyways - and we want to comply with that instead of C-style naming like in Views (e.g. views_field_handler::get_options()).
Another point to consider would be dropping the "get" prefix. For PHP, method names like getIterator() are standard, but in fact the "get" doesn't say anything, and there's no exact line to draw between functions with a "get" prefix vs. functions without. What's "get", what's "load", what's "format" and "theme"? Imho, they're all the same essentially, apart from implementation issues like "retrieves stuff from the database" or "retrieves stuff via the theme system" or similar.
If I would create Version Control API from scratch, I'd do it without "get" prefixes. That's also standard in Qt APIs, and Qt is of course teh r0xx0rz (as everyone knows). Input from Sam highly appreciated.
Yep, helper function, needs to stay where it is.
(nitpicking: not "loose", but "lose")
As I stated in our previous email discussion, I'm not yet convinced that items should be split into two different subclasses. If we go with a single VersionControlItem class then we still need this function (isFile(), isDirectory()).
Further comments:
is_null($this->commitOperations)).$repository->urls()->commitView($operation) or similar.That's all for now! Looking forward to the next revision :]
Comment #3
jpetso commentedMore appropriate issue title.
Comment #4
jpetso commentedAlso, this is a task, not a feature request.
Comment #5
sdboyer commentedWhew. Lotsa stuff to comment on. I WILL get to this in the next 36 hours - just commenting for now to say I've noted this is here :)
Comment #6
marvil07 commentedAbout code standards: Drupal coding standards says under Naming Conventions > Functions and Methods:
So, it seems like C-standard is the right choice, but like you said I see DBTNG _is_ using camelCase on methods.. uhmm I'm some kind of confused.
... well, after talking on irc, merlinofchaos give me the key answer:
So, like you said, let's use camelCase.
I'm attempting to remove all "get"s, except where the context do not let see what type is being returned(but I could not see one of those cases :D).
Re-joined directory and file on item class()
TODO on code:
- unify get, format, load in one method if applies
- remove fetch*() methods because with objects we can do that on demand whenever the API user needs the information.
(I do not know how to represent interfaces on dia, so make it on code)
TODO on decitions:
TODO on analysis:
About news:
functions outside classes:
- all file:
- versioncontrol.pages.inc
convert sub-modules on interfaces for backends(commit_restrictions, commitlog)
- Sorry about the bad english, I'd make my best effort :p.
- I think is a _good_ idea to user commiter instead of author, because in centralized VCSs we can only afirm the user that commit it, who _is not_ necessary the author.
I'm really in favor of do it manually :D, but I thought first attempts are really more understandable using uml diagrams and to ease the communication.
But now, like you said, it's time to really _do it_, so do you want that I create the github clone of versioncontrol module?
LOL, the problem here was the allowed extensions :p
Comment #7
sdboyer commented(if I omit responding to something, consider it a thumbs-up)
The coding standards page is out of date with respect to classes. Most people who've done OO in drupal disagree with merlinofchaos on that point, myself included :) Truth is, as much as I love Earl, views is increasingly becoming the island bastion of C-style in an ocean of CamelCase. Which is another way of saying that I can't even imagine the necessary chain of events that would get core back to C-style for classes. Moreover, there was an explicit discussion (#260220: OOP standards) about the appropriate formatting, and the direction we went was CamelCase, in large part because it's the PHP standard. It's also not quite true to say that DBTNG was the first thing that went into core that made heavy use of classes - it had been standard fare in Simpletest for months prior to DBTNG getting patched in.
And, here's one of those super-minor nits that I can totally imagine us arguing over forever: I think class names should be Versioncontrol, not VersionControl. I don't like camelcasing strictly at word boundaries because it's not especially meaningful - rather, we camelcase at conceptual boundaries, which are often (but not always) word boundaries. I.e., the same way we use underscores: the module name is versioncontrol, not version_control. I think the reasons why are obvious in C-style - so shouldn't the same principle apply with CamelCase? I'll stick with the form we're using for the remainder of this post, at least, though...
I'm actually gonna disagree with you (jpetso) on the removal of initial verbs from the method names. Your reasoning is sound, with the exception of the fact that it basically assumes read-only. Which all we need now, of course, but if we're ever to introduce support for any kind of writing into vcsapi, then we'd be immediately confronted by namespacing confusion, because we'd NEED that verb there to tell us the sort of action we're performing on any one of these things. Maybe we never get around to supporting writing, but in the interest of avoiding refactoring - and forcing any modules that eventually implement this API to refactor - I'd rather use more explicit method names cases where we can imagine an ambiguity arising, even if it doesn't exist now.
Now, onto jpetso's list:
I believe I mentioned somewhere else, but the whole approach to
versioncontrol_backend_implements()really needs to be overhauled. Not only is the current approach infeasible for OO (simply checking if a function exists won't help), but it's FAR better done via interfaces and/or static properties. It's a basic good OO rule that you want to put that sort of metadata somewhere that you can retrieve it and use it prior to object instantiation, so let's be good OO citizens on that one :)Comment #8
jpetso commentedSome of the points that are still open after sdboyer's comment.
ad CamelCasing: The module name "versioncontrol" is not "version_control" because that's a major pain in the neck to write over and over again, and it doesn't look cool. Neither of these reasons apply to VersionControl. And as you all know, a module that doesn't prefix its own C-style name to functions is evil. Of course, if it were for myself, I'd probably just prefix "Vc" to each class, like I did with "Tf" for transformations, and afaik there's no styleguide that tells us how to name classes. All in all, I just find "Versioncontrol" totally unstylish, it's neither fish nor fowl. But as you said, this is something that can be discussed to death with no end, so I'll just leave that issue to you (Sam) so that I won't need to argue about it because it makes little difference in practice. (Still... think of the coolness factor! DX!!1! erm.)
ad 3. I did not say "remove verbs from method names". I said "remove getter verbs from method names". Any setter verbs must of course be preserved, including methods that perform any "write" action on stuff. Like,
$repository->setName($repository->name());. (Hopefully I addressed the same issue that bothered you. If not, please clarify.)ad 7. Hm, I thought I mentioned that in one of these recent mails. Anyways.
An account, in its current incarnation, is uniquely identified by either the uid or the combination of repository and username, with a 1:1 mapping in each direction. However, that's not good enough as we want to support multiple accounts per user and repository, and for that, the uid to repository/username relation is a 1:n one. What I had in mind is some entity providing facilities like this:
We could well use this wherever the exact combination of uid/repository/username is not known, including on some of the account forms (for user N and, er, *which* repo/username combination?) and in places where we want to refer to such "partial" accounts but don't want to fetch all information about them from the database. See occurrences of versioncontrol_get_accounts() to (hopefully) get a better idea of why we need this, I find it a bit hard to explain.
Of course, the above API is utter crap, which is the main reason why Version Control API 6.x-1.0 still doesn't support multiple accounts per user and repository - I just didn't know how to present the information in a way that's sufficiently accessible to the developer. Any good ideas on that topic will save my day.
ad 13. I just meant dia2code, not diagramming in itself. Code generated from stuff like UML is evil most of the time, while proper diagrams can totally convey useful information fast, and I appreciate the diagram here too.
ad versioncontrol_backend_implements(): While I think that this approach does work pretty well outside of OOP, it definitely needs to be replaced by interfaces. The challenge here is to find combinations of functions that will be implemented together, because one method doesn't make sense without another one. The split between database storage and on-the-fly-retrieval of information is an obvious starting point, although I believe the final interfaces should be more fine-grained to allow less-featured backends to work in some scenarious as well.
Comment #9
marvil07 commentedSummary
from sunday irc meeting:
Start working on account stuff(now there are two classes: VersioncontrolVcsAccount and VersioncontrolAccount)
updating TODO on code
- unify get, format, load in one method if applies
- remove fetch*() methods because with objects we can do that on demand whenever the API user needs the information.
(I do not know how to represent interfaces on dia, so make it on code)
Replace versioncontrol_backend_implements() approach with one interface per feature
Comment #10
marvil07 commentedSo, this task is almost done, so all feedback would be really appreciated.
The actual code is on oop branch at github(see also git backend oop branch to a real backend compatible)
Comment #11
marvil07 commentedthere is still some things to do, but all pointed in one issue #595930: from github to d.o cvs(aka start 6.x-2.0-dev and get access), so closing this