V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
857681664
V2EX  ›  程序员

抱着想写好质量代码的心,然后遇到一个完全不管代码质量的人合作,真是糟心

  •  2
     
  •   857681664 ·
    zshnb · 34 天前 · 9839 次点击
    这是一个创建于 34 天前的主题,其中的信息可能已经有所发展或是发生改变。

    项目框架已经搭好用 springboot3 和 JPA ,然后他居然在 repository 里写了个 insert 方法,而且还是用 nativeSQL ,当然可能人家没用过 JPA ,那也算了。

    然后一个发邮件的功能,他说调试了一天才搞定,然后我一看他的代码,在发邮件的函数里用 java 自带的 http client ,每发一封就 new 一个,就算不用 sprigbooot 的 rest template ,好歹也用一下 okhttpclient 吧,而且也不用 bean 管理一下。然后发邮件有个验证码机制,有有效期之类的,我本来的想法是用单独的表管理所有验证方式,比如注册验证邮件,改密码验证邮件,还有大概率手机验证,2FA 之类的,然后他直接把 token 和过期时间存 user 表里了。

    还有很多小细节,比如全局捕获异常也不设置 http 状态码,直接默认都 200 (项目定的 rest 风格),有 loback 也不用,异常直接 printstack ,也从不管已经存在的代码,比如已经有 util 包和 Util 类了,还要新建 utils 包和 Util 类,异常码也是,明明有个 user_not_found 了,还要在一个他写的重复判断用户是否存在的逻辑里加一个 no_email 的错误码,反正我也不想管了,把我负责的 api 弄稳妥就行。

    116 条回复    2024-05-14 10:51:06 +08:00
    1  2  
    zhang77555
        101
    zhang77555  
       33 天前
    建议慎重
    公司规模不大,这事儿没必要管,你有技术追求早晚会离开。
    公司规模大,这事儿没必要管,你也不清楚他跟领导关系如何,说了也没啥好处,真要你接锅时跑路也无所谓,代码烂总有优化空间还有利于团队生存,项目运行太好团队存在感太低这个环境下容易被砍[doge]
    至于想做个高质量项目啥的,公司项目你又不能开源,而且任何商业项目随着开发周期增长很难说不变成一坨,只是快和慢的差别,能吹的项目也从来不是啥代码质量,而是项目依托于平台所做的事情
    iintothewind
        102
    iintothewind  
       33 天前
    @857681664 #79 多经历一些老系统就知道了, 离谱的事情真的非常多.

    不是说你, 如果我如果拿我自己对代码的标准要求别人, 那估计基本其他人写的那些东西都得回炉重造.

    但是看多了, 麻木了.
    iyaozhen
        103
    iyaozhen  
       33 天前
    和昨天老哥一样 /t/1039891
    我认为还是环境问题,你不换个公司,只能让这些劣币驱逐良币了
    rxswift
        104
    rxswift  
       33 天前
    我也有个这样的前同事
    morrieati
        105
    morrieati  
       33 天前
    @857681664 #97 大部分场景下可以相信数据库的性能,supabase user 表的定义我贴在下面:
    ```SQL
    create table
    auth.users (
    instance_id uuid null,
    id uuid not null,
    aud character varying(255) null,
    role character varying(255) null,
    email character varying(255) null,
    encrypted_password character varying(255) null,
    email_confirmed_at timestamp with time zone null,
    invited_at timestamp with time zone null,
    confirmation_token character varying(255) null,
    confirmation_sent_at timestamp with time zone null,
    recovery_token character varying(255) null,
    recovery_sent_at timestamp with time zone null,
    email_change_token_new character varying(255) null,
    email_change character varying(255) null,
    email_change_sent_at timestamp with time zone null,
    last_sign_in_at timestamp with time zone null,
    raw_app_meta_data jsonb null,
    raw_user_meta_data jsonb null,
    is_super_admin boolean null,
    created_at timestamp with time zone null,
    updated_at timestamp with time zone null,
    phone text null default null::character varying,
    phone_confirmed_at timestamp with time zone null,
    phone_change text null default ''::character varying,
    phone_change_token character varying(255) null default ''::character varying,
    phone_change_sent_at timestamp with time zone null,
    confirmed_at timestamp with time zone null,
    email_change_token_current character varying(255) null default ''::character varying,
    email_change_confirm_status smallint null default 0,
    banned_until timestamp with time zone null,
    reauthentication_token character varying(255) null default ''::character varying,
    reauthentication_sent_at timestamp with time zone null,
    is_sso_user boolean not null default false,
    deleted_at timestamp with time zone null,
    constraint users_pkey primary key (id),
    constraint users_phone_key unique (phone),
    constraint users_email_change_confirm_status_check check (
    (
    (email_change_confirm_status >= 0)
    and (email_change_confirm_status <= 2)
    )
    )
    ) tablespace pg_default;

    create index if not exists users_instance_id_idx on auth.users using btree (instance_id) tablespace pg_default;

    create index if not exists users_instance_id_email_idx on auth.users using btree (instance_id, lower((email)::text)) tablespace pg_default;

    create unique index confirmation_token_idx on auth.users using btree (confirmation_token)
    where
    ((confirmation_token)::text !~ '^[0-9 ]*$'::text) tablespace pg_default;

    create unique index recovery_token_idx on auth.users using btree (recovery_token)
    where
    ((recovery_token)::text !~ '^[0-9 ]*$'::text) tablespace pg_default;

    create unique index email_change_token_current_idx on auth.users using btree (email_change_token_current)
    where
    (
    (email_change_token_current)::text !~ '^[0-9 ]*$'::text
    ) tablespace pg_default;

    create unique index email_change_token_new_idx on auth.users using btree (email_change_token_new)
    where
    (
    (email_change_token_new)::text !~ '^[0-9 ]*$'::text
    ) tablespace pg_default;

    create unique index reauthentication_token_idx on auth.users using btree (reauthentication_token)
    where
    (
    (reauthentication_token)::text !~ '^[0-9 ]*$'::text
    ) tablespace pg_default;

    create unique index users_email_partial_key on auth.users using btree (email)
    where
    (is_sso_user = false) tablespace pg_default;

    create trigger on_auth_user_created
    after insert on auth.users for each row
    execute function handle_new_user ();
    ```
    destiny0114
        106
    destiny0114  
       33 天前
    @857681664 这种情况我觉得不用待太久,可以找别家公司了。
    wzdsfl
        107
    wzdsfl  
       33 天前
    @GeekGao #9 都在一个项目里做事,OP 这么认真对待想做好这件事,有人拖后腿肯定不爽,而且往代码里拉屎最后说不定还得 OP 自己啃
    dif
        108
    dif  
       33 天前
    大概率是不会吧,JPA 有 JPA 的写法,MyBatis 有 MyBatis 的写法。
    GeekGao
        109
    GeekGao  
       33 天前
    @wzdsfl 首先要知道自己能掌控的事情范围,超出自己责任和能力范围的事儿不爽也仅限于不爽(心理病、内分泌失调、心脏病等同事、公司不负责啊)。

    btw:没准这系统代码 1 年后就没任何商业价值被遗弃了,或者下个季度就裁员了…
    Mantext1989
        110
    Mantext1989  
       33 天前
    你教教他
    dcdlove
        111
    dcdlove  
       33 天前
    @857681664 #20 我们的后端全是这种德性,全是来糟蹋世界的
    morgan1freeman
        112
    morgan1freeman  
       33 天前
    说一下我的新路历程吧,

    刚毕业的时候,我也是跟楼主一样的想法,觉得要注重代码质量,多关注阅读代码人的感受,后来真的想明白了,大部分人就混口饭吃罢了,何况 绩效 收入 升职 跟你技术能力 真的有那么大的关系么?你有追求,可以去个人项目里面去追求代码可读性,团队里面 现有代码什么风格,就跟着继续玩就好了,反正升职加薪 跟 代码 技术大概率没有半毛钱关系,关键在于你在团队里面的位置,以及你在哪个圈子里面

    后面工作几年后发现,就这样吧,反正领导也不在乎,也没人为良好可阅读的代码付费,何必自我纠结,完成任务就好。

    其实烂代码的团队,比较吃亏的是团队里面的边缘人,因为很多业务代码 ,第一版不是边缘人写的,因为很多重点项目都是先让领导亲信去写,只要完成任务即可,没有人在乎架构跟代码质量,完成任务就能拿各种奖项 KPI 绩效刷一波。

    但是第二三版,改动的时候,这个时候产品要做改动,边缘人就会被派上场,因为项目已经完成,再投入资源去修修改改,通常这种活不会有什么功绩可说,边缘人这个时候就会被派去 填坑吃屎,而且阅读狗屎代码,吃屎真的就容易踩坑,有的时候吃自己的屎,还能闻出那股屎位,别人写的屎,真的就是摸不清脉络,可能一个方法上几百行,然后各种复制粘贴,漏了一个改动还容易吃 bug 背锅
    qinfengge
        113
    qinfengge  
       33 天前
    @857681664 #84 这真的不是培训班出来的吗
    james122333
        114
    james122333  
       33 天前 via Android
    如果约定好使用什么那就使用什么 但使用框架等同质量好或有保证我不认同 一个框架要怎么使用也没有定论 毕竟虽然 java 封装很糟心 但你研究久了还是可以依照喜好定义
    我就曾经用 mybatis 但我不想用智障 xml 也想保持灵活性和直观 直接用 mybatis 底层方法建立 statement 过 这样是不是在你眼裏是劣币?
    如何把项目搞的傻瓜化才是真的 不限任何方法
    我看过太多屎一般的 spring 项目 内部用的工具也是一堆
    james122333
        115
    james122333  
       33 天前 via Android
    至于代码质量的审美 不可能统一的 因为每个人历程不一样 以我的经验 能够单步除错就能够找到原因的多半不会太差 而 springboot 用註解本身就会降低可除错性
    LookUpAndSmile
        116
    LookUpAndSmile  
       33 天前
    @sagaxu 哈哈···,都是过来人啊
    1  2  
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2457 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 03:11 · PVG 11:11 · LAX 20:11 · JFK 23:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.