公司项目越写越烂,想重构得不到支持,该走还是该留?

2015-05-18 14:46:28 +08:00
 ChoateYao

在这家公司已经快两年了,从项目的开始就一直在。
进来很多同事也有很多同事离职,代码腐烂的气息越来越重。
期间提出很多建议,如写单元测试、重构代码、整理文档、统一代码风格。
但是基本上只是纸上谈兵,领导每次都给予团队人员不熟悉、每个人的代码风格都不一样等说法。
那我究竟是走还是留呢?每天过来上班看着任务列表就不想工作,实在是不想在这个项目上面写任何代码了。

10004 次点击
所在节点    程序员
88 条回复
JamesRuan
2015-05-20 02:36:28 +08:00
@laotaitai 为啥我觉得应该是clean>work>performance?代码不管对不对,首先是思想的体现,代码dirty等同与思想dirty,改来改去改成能work了,谈何维护?
Navee
2015-05-20 09:57:58 +08:00
对已上线的稳定项目进行重构风险十分大!
除非你们有完善的测试 , 否则不建议这么做 .
你倒是可以在项目中的新功能,按照新的方案实现
huijiewei
2015-05-21 10:23:34 +08:00
private function dMyQA($request, $response, $app)
{
$pageno = $request['pageNo'] ? $request['pageNo'] : 1;
//$request['uid']='18000000000';$request['date']=0;
if (!isset($request['uid']) || empty($request['uid'])) {
return (array('code' => '-1', 'message' => '缺少uid'));
}
$jxs = $this->quanxian($request['uid'], '0');
if ($jxs['jxs_brand']) {
$jxs['jxs_brand'] = str_replace('[', '', $jxs['jxs_brand']);
$jxs['jxs_brand'] = str_replace(']', '', $jxs['jxs_brand']);
$jxs['jxs_brand'] = str_replace('"', '', $jxs['jxs_brand']);
$brand = $this->db->create_mapper('product_lib_brand')->select('id')->where('pid in (' . $jxs['jxs_brand'] . ')')->find_all_by();
$brandlist = '';
foreach ($brand as $brand1) {
if ($brandlist) {
$brandlist .= ',' . $brand1['id'];
} else {
$brandlist = $brand1['id'];
}
}
$where = " and (car_name in (" . $brandlist . ") or car_name is null or car_name='')";
} else {
$where = '';
}

//print_r($brandlist);exit;
//$obj=$this->db->create_mapper('qa')
//->where(array('ans_user_id'=>$request['uid']));
if ($request['type'] == '1') {
$sqlcount = 'SELECT count(*) as count from qa as a left join qa as b on b.id=a.ask_id where a.ask_id<>0 and b.is_active=1 and a.ans_user_id=' . $request['uid']. ' and a.ans_from_id='.$request['jxs_id'].' GROUP BY a.ask_id';
$count = $this->db->getOne($sqlcount);
$page = $this->page($count, $pageno);
$sql = $sql = 'SELECT b.id as qid,b.title,b.cat,a.ans_user_name as qname,a.content as acontent,a.create_time,a.reply_num,c.name as class FROM qa as a left join qa as b on b.id=a.ask_id left join qa_cat as c on c.id=b.cat where a.ask_id<>0 and b.is_active=1 and a.ans_user_id=' . $request['uid'] . ' and a.ans_from_id='. $request['jxs_id'] .' GROUP BY a.ask_id order by a.create_time desc limit ' . $page['start'] . ',' . $page['pagesize'] ;

$row = $this->db->get_all($sql);
//print_r($sql);exit;
//$obj->where('ask_id<>0 and is_active=1');
} else {
$sqlcount = 'SELECT count(*) as count from qa left join qa_cat on qa_cat.id=qa.cat where qa.ask_id=0 and qa.is_active=1 and qa.id not in (select distinct ask_id from qa where ans_user_id=' . $request['uid'] . ') and dep_role=' . $jxs['depart_id'] . $where;////qa as b ON b.id=a.ask_id'; //where a.id=145 or a.id=139';
//$count=$this->db->getOne($sqlcount);
//echo $sqlcount;exit;
$page = $this->page($count, $pageno);
$sql = 'SELECT a.id as qid,a.car_name,a.title,a.cat,a.ans_user_name as qname,a.content as acontent,a.create_time,a.reply_num,c.name as class FROM qa as a left join qa_cat as c on c.id=a.cat where ask_id=0 and is_active=1 and a.id not in (select distinct ask_id from qa where ans_user_id=' . $request['uid'] . ') and c.dep_role=' . $jxs['depart_id'] . $where . ' order by a.create_time desc limit ' . $page['start'] . ',' . $page['pagesize'];
$row = $this->db->get_all($sql);
//print_r($sql);exit;
//$row=$this->db->query($sql);
//$obj->where('ask_id=0 and is_active=1');
}
//$count=$obj->count_by();


//$row=$obj->limit($page['pagesize'],$page['start'])->select('a.id as qid,a.title,a.cat,a.ans_user_name as qname,a.content as acontent,a.create_time,a.reply_num')
//->left_join('qa_cat as c','c.id=a.cat','c.name as class')
//->find_all_by();
foreach ($row as $key => $val) {
$row[$key]['qname'] = $this->hidtel($val['qname']);
$row[$key]['date'] = date('Y-m-d H:i:s', $val['create_time']);
//$row[$key]['url']=$this->h5url.'ywbd/do_index&id='.$val['qid'];
if ($request['type'] == '1') {
unset($row[$key]['reply_num']);
}
}
$row = $this->clearNull($row);
return (array('code' => '1', 'pageNo' => $page['pageno'], 'pageTotal' => $page['pagetotal'], 'pageSize' => $page['pagesize'], 'message' => 'success ', data => $row));

}

这种代码怎么维护,求老司机带

系统里面全是这种代码
nxbtch
2015-05-21 11:34:27 +08:00
走吧
xinxin2025
2016-09-02 10:44:33 +08:00
@kamal 嗯,我读过类似的文章,我也知道不能大规模重构,我现在就是想一个模块一个模块把重复的功能、复杂的代码都重构,重构当然不是一时半会的事情。但是领导不支持我也木有办法。

其实我现在也是类似的情况。
其实我也没想过一下子就大规模重构,但是,身边的同事,经常连 抽取函数(比如复杂的判断条件,一个几百行上千行的函数中到处出现可以各自为政的部分,至于重复代码我就不说了,那个,多得是~~)
更有甚者,他们连 代码缩进都懒得捋一下......
这些天刚结的一个项目,我是固件的主导,但因为我一下子有点冒进的重构,最后惹出了点麻烦,时间赶得很紧。
也因此,破坏了一些原有功能(我知道,这是我的错,但这不代表重构是错的)
你也说过,代码日益腐烂,我相信你一定能理解我的心情。
结果,现在,原来还挺开明的领导越来越,,,甚至直接放弃我改动过的项目,宁可重新回到原框架上,让另一个同事重新理。
所谓理就是,不改动原有代码,对,就是连缩进都不动那种!
然后加进新功能而已。
还留下一句评论:做项目开发(应用)打击创新,还说华为要求任何项目使用原有成熟代码一定要超过 70%,只允许 30%创新。
可是,重构也叫创新?我承认我对重构做得不够谨慎和小心。但是,这样......诶

我几乎要崩溃了!也想过离开。
可是,我有更多的时候想过离开,有更多比这个更加充分的理由,但都没有离开。
何况,从我以往的工作经验来看,这家公司在这方面并不是唯一的固执者,更不是最固执的,即使换,恐怕也是一样。
于是我就只能在 强迫自己 和 不甘 之间苦苦挣扎。
xinxin2025
2016-09-02 10:47:05 +08:00
但是,现在,关于重构,我认为,确实有很多东西值得商榷!
一件事情,应该知道好处也要知道坏处。
知道什么时候做,也该知道什么时候不该做。

具体,还在整理思路中。
比如 MF 就没考虑到一件事情,做这件事情的 心理困境。(大家的心理困境)
kamal
2016-09-18 09:44:41 +08:00
@xinxin2025
领导给过你机会,你搞砸了。

这不是重构不重构的问题,是对你的技术不放心。
要想赢回信任,要花很多时间,你能保证不出错,再考虑重构吧。
songsong
2017-05-04 18:00:43 +08:00
辞职吧 , 跑路吧

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/191926

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX