Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
/**
* Always returns true.
*/
public boolean isAvailable() {
return false;
}/** * Always returns true. */ public boolean isAvailable() { return false; }
#define false true;// FIXME: Хак, траляля [name]и пользовать вкладку tasks
// описание
// Dear maintainer:
//
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
//
// total_hours_wasted_here = 37//When I wrote this, only God and I understood what I was doing
//Now, God only knows// I'm sorry.// Magic. Do not touch. /* * You may think you know what the following code does. * But you dont. Trust me. * Fiddle with it, and youll spend many a sleepless * night cursing the moment you thought youd be clever * enough to "optimize" the code below. * Now close this file and go play with something else. */ // If this comment is removed the program will blow up
((void(*)(void))0)();// Magic. Do not touch.
var profilesFound = profiles.GetProfiles(x => !(
x.ApplicationName != applicationName ||
!(usernameToMatch == null ||
x.Username == usernameToMatch) ||
!(userInactiveSinceDate == null ||
x.LastActivityDate <= (DateTime)userInactiveSinceDate) ||
!(authenticationOption == ProfileAuthenticationOption.Anonymous &&
x.IsAnonymous ||
authenticationOption == ProfileAuthenticationOption.Authenticated &&
!x.IsAnonymous)
));Как ни странно — все работает. Но, судя по вашей статье, не совсем понятно — это полезный или вредный комментарий. Вроде бы места не много занимает.{((void(*)(void))0)();} // что-то из черной магии
*reinterpret_cast<int *>(&showFlags) = behavior.value("showFlags", 0xfffffff);
template<typename T, int N, X = int>
Q_INLINE_TEMPLATE X strToEnum(const T &str, const char *(&strings)[N])
{
for(int i=0;i<=N;i++) {
if(QLatin1String(strings[i]) == str)
return static_cast(i);
}
return static_cast(-1);
}
template<typename T, int N, X = int>
Q_INLINE_TEMPLATE int strToEnum(const T &str, const char *(&strings)[N])
{
for(int i=0;i<=N;i++) {
if(QLatin1String(strings[i]) == str)
return static_cast<X>(i);
}
return static_cast<X>(-1);
}
* This source code was highlighted with Source Code Highlighter. if (!!(conf = qobject_cast<Conference *>(unit))) {
foreach (ChatUnit *u, conf->lowerUnits()) {
if (Buddy *buddy = qobject_cast<Buddy*>(u))
addContact(buddy);
}
}
* This source code was highlighted with Source Code Highlighter.// Magic. Do not touch.
var profilesFound = profiles.GetProfiles(x => (
x.ApplicationName == applicationName && (
usernameToMatch == null || x.Username == usernameToMatch
) && (
userInactiveSinceDate == null ||
x.LastActivityDate <= (DateTime)userInactiveSinceDate
) && (
(x.IsAnonymous && authenticationOption == ProfileAuthenticationOption.Anonymous)
||
(!x.IsAnonymous && authenticationOption == ProfileAuthenticationOption.Authenticated)
)
));
isCorrectApplication (x) {
return x.ApplicationName == applicationName;
}
isUsernameMatched (x) {
return usernameToMatch == null || x.Username == usernameToMatch;
}
isUserActive (x) {
return userInactiveSinceDate == null ||
x.LastActivityDate <= (DateTime)userInactiveSinceDate;
}
isAuthenticationAllowed (x) {
return isAnonymousAuthentication(x) || isProfileAuthentication(x);
}
isAnonymousAuthentication (x) {
return (x.IsAnonymous && authenticationOption == ProfileAuthenticationOption.Anonymous);
}
isProfileAuthentication (x) {
return (!x.IsAnonymous && authenticationOption == ProfileAuthenticationOption.Authenticated)
}
var profilesFound = profiles.GetProfiles(x => (
isCorrectApplication(x) &&
isUsernameMatched(x) &&
isUserActive(x) &&
isAuthenticationAllowed(x)
));
$profileProvider->addChecker(new AppIdentityChecker($profileProvider->getApp(), $app));
$profileProvider->addChecker(new UserIdentityChecker($profileProvider->getUser(), $user));
$profileProvider->addChecker(new UserStatusChecker($user));
$authChecker = AuthCheckerFactory::createChecker($profileProvider->getAuthType(), $user);
$profileProvider->addChecker($authChecker);
if ($profileProvider->check()) {
...
}
В основном это вызовы других методов + пустые строки + скобки блоков и всякие IF-ы.
return userRepository.Get(user.Id).Name;, ну или ненамного больше, а все остальное — нарушение SRP.все-равно разражают…
тогда когда меняешь код — забываешь поменять доку, она ведь свёрнутая и не обращаешь на неё внимание.
только дилетанты, не имеющие опыта работы в команде и работы над крупными проектами, считают отсутствие комментариев нормой.
почему эта функция работает именно так, а не иначе, как могло бы казаться
Комментарии в коде — полезные, бессмысленные, вредные?