Browse Category: Tech

JPA/Hibernate Tips

  • Best Practices
    • Declare identifier properties on persistent classes with NO business meaning
    • Identify natural/business key – equals/hashcode
    • Do not treat exceptions as recoverable – rollback the transaction and close the connection
    • Prefer lazy fetching for associations
    • Prefer bidirectional associations
    • Use bind variables (NO string manipulations)
    • Using second-level caching for those entity classes that represent
      • Data that changes rarely
      • Noncritical data (eg. Content-management data)
      • Data that’s local to the application and not modified by other applications

Continue Reading

产品与摩托车

昨天在路上看到骑摩托车的人,善于从生活中总结道理的我,又灵光一现。。。

车开动的时候,摩托是平衡的,稳稳当当,左闪右避,灵活地向着目的地行进。红灯了,骄傲的骑手要停下来,这时候,他一定要稍稍侧身,单脚点地,才能保持平衡。摩托车静止时需要支撑,可行进起来却是玉树临风。

我想到了做产品,做项目的时候,我最大的问题,我总是期望这个产品达到一个完美的状态:代码干净利落,业务逻辑清晰,文档和流程完善。想来我追求的是一个结果,一个静止状态。可产品本来就不是静止的,做产品就像是骑摩托,一开始就想让他稳稳的站住,那他永远平衡不了,永远不能向前。总要行进起来才行,才能找到感觉。也像学自行车时一样,行进起来也许跌跌撞撞,也许甚至需要两个辅助的轮子。产品就是这辆自行车,这辆摩托,马路公路是市场,旁边的车有竞争对手,也有毫不相干的人或事。要想到达目的地,要在乎的一定不是怎样让他稳稳站住,而是找好方向,流畅地开起来。实现功能,解决问题,应对挑战。为了有可能的需求预留接口,即使是举手之劳,也许并没有意义。因为这个需求真的来了的时候,也许不会再有人记得这个接口,或者接口已经不是标准的。外部环境变化之快,谁也无法预言,即使是不远的将来,甚至只是下一个sprint。代码的重用,封装也是一样,有能力做好的封装,提供以后做多态的可能,当然很好,但是你永远不知道谁会接手你的程序,别人是否能看懂你在里面花费的心思。这时候,比文档更重要的是测试,明确的告诉后面的人,后面的功能,我不在乎你怎么搞,但是不要搞坏我的功能。我想程序员之间的合约就是市场标准和单元测试。

Continue Reading

[Tips] AWS Solution Architect – Associate

  • Amazon S3 buckets in all Regions provide read-after-write consistency for PUTS of new objects and eventual consistency for overwrite PUTS and DELETES.
  • High IO needs -> RAID 10 : Striped and Mirrored, Good Redundancy, Good Performance
  • S3
    • Standard : 99.999999999% durability, 99.99% availability
    • S3-IA (Infrequent Access) : 99.999999999% durability, 99.9% availability (You should expect the same latency and throughput performance as Amazon S3 Standard when using Standard – IA.)
    • S3-RRS (Reduced Redundancy Storage) : 99.99% durability, 99.99% availability
    • Glacier : 99.999999999% durability, 3-5 hours via the Amazon S3 APIs or Management Console

Continue Reading