🔖编程记录分享~

💡Record and Share


git总结

Git 与 GitHub 全面指南:从基础到团队协作 一、核心概念解析 工具 定位 核心功能 类比说明 Git 分布式版本控制系统 代码版本管理、分支操作、历史追踪 代码的"时间机器" GitHub 基于 Git 的代码托管平台 代码托管、协作开发、项目管理 代码的"社交网络" 二、Git 核心工作流(开发者视角) 1. 日常开发循环 graph LR A[git checkout -b feature] --> B[代码修改] B --> C[git add .] C --> D[git commit -m"描述"] D --> E[git push origin feature] E --> F[创建PR/MR] F --> G[代码评审] G --> H[合并到主分支] 2. 必备 Git 命令手册 命令 使用场景 示例 git clone 克隆仓库 git clone https://github.com/user/repo.git git status 查看状态 git status git add 暂存文件 git add file.txt git commit 提交更改 git commit -m "修复登录bug" git push 推送代码 git push origin main git pull 拉取更新 git pull --rebase git branch 分支管理 git branch -d old-feature git checkout 切换分支 git checkout -b new-feature git merge 合并分支 git merge feature/login git rebase 变基操作 git rebase main git stash 暂存修改 git stash pop git log 查看历史 git log --oneline --graph 三、GitHub 团队协作实战 1. 标准协作流程 sequenceDiagram 开发者->>+GitHub: 创建特性分支(feature/login) 开发者->>+本地: 开发并提交代码 开发者->>+GitHub: 推送分支并创建PR 团队->>+PR页面: 代码审查/讨论 团队->>+GitHub: 批准PR 维护者->>+GitHub: 合并到main分支 GitHub->>+CI系统: 触发自动化测试/部署 2. 高效协作技巧 分支策略

Read more →

html/css使用经验总结

HTML/CSS 使用经验总结 一、核心原则 语义化优先 <!-- 错误示例 --> <div onclick="goToPage()">点击这里</div> <!-- 正确示例 --> <a href="/page" role="button">跳转页面</a> 样式与结构分离 避免行内样式(style属性) 使用外部CSS文件(<link rel="stylesheet">) 类名语义化(.card-container而非.div1) 二、布局实战技巧 1. Flexbox 经典布局 /* 三栏响应式布局 */ .container { display: flex; flex-wrap: wrap; } .sidebar { flex: 0 0 250px; } .main { flex: 1 1 600px; } .widget { flex: 0 1 200px; } /* 移动端适配 */ @media (max-width: 768px) { .container > * { flex: 1 1 100%; } } 2. Grid 复杂布局 /* 杂志式布局 */ .grid-layout { display: grid; grid-template: "header header" 80px "sidebar main" 1fr "footer footer" 60px / 200px 1fr; } .header { grid-area: header; } .sidebar { grid-area: sidebar; } 三、常见问题解决方案 1. 垂直居中 /* 现代方案 */ .center-box { display: grid; place-items: center; } /* 传统方案(兼容旧浏览器) */ .legacy-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } 2. 清除浮动 /* 清除浮动类 */ .clearfix::after { content: ""; display: table; clear: both; } 3. 文本溢出处理 .ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* 多行文本溢出 */ .multi-ellipsis { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; /* 控制行数 */ overflow: hidden; } 四、性能优化实践 渲染性能 /* 启用GPU加速 */ .animate-element { transform: translateZ(0); will-change: transform; } /* 避免布局抖动 */ .avoid-reflow { position: absolute; opacity: 0; transition: opacity 0.3s; } 加载优化 <!-- 延迟非关键CSS --> <link rel="preload" href="critical.css" as="style"> <link rel="stylesheet" href="non-critical.css" media="print" onload="this.media='all'"> 五、响应式设计要点 1. 移动优先策略 /* 基础样式(移动端) */ .card { padding: 1rem; } /* 平板适配 */ @media (min-width: 768px) { .card { padding: 1.5rem; } } /* 桌面端适配 */ @media (min-width: 1024px) { .card { padding: 2rem; max-width: 1200px; } } 2. 响应式图片 <picture> <source srcset="large.jpg" media="(min-width: 1200px)"> <source srcset="medium.jpg" media="(min-width: 768px)"> <img src="small.jpg" alt="响应式图片"> </picture> 六、CSS 架构建议 命名规范 BEM 模式:.block__element--modifier 作用域限定:.component-name .element 变量管理 :root { --primary-color: #3498db; --spacing-unit: 8px; } .button { background: var(--primary-color); padding: calc(var(--spacing-unit) * 2); } 七、调试技巧 浏览器开发者工具 元素检查(Ctrl+Shift+C) 强制状态(:hover/:active) 设备模式测试响应式 CSS验证工具 使用 W3C CSS Validator ESLint + stylelint 代码检查 八、学习资源推荐 官方文档 MDN Web Docs CSS Tricks 实战平台 CodePen 创意实验 Frontend Mentor 项目挑战 经验总结:HTML/CSS 的核心在于理解文档流、盒模型和选择器特异性。通过语义化标记、现代布局技术(Flex/Grid)和性能优化实践,可构建既美观又高效的界面。持续关注 CSS WG 的新特性(如容器查询、层叠层)保持技术前瞻性。

Read more →

Spring注解

Spring Framework 核心注解深度解析 一、IOC/DI 容器注解 1. 组件扫描注解 注解 作用 参数说明 使用示例 @ComponentScan 包扫描 basePackages:扫描包路径 excludeFilters:排除过滤器 @ComponentScan("com.example") @Component 通用组件 value:Bean名称 @Component("userService") @Service 业务层 同@Component @Service @Repository 持久层 自动转换数据访问异常 @Repository @Controller 控制层 MVC专用 @Controller @Configuration 配置类 声明配置类 @Configuration 原理流程: graph TD A[启动类] --> B[@ComponentScan] B --> C[扫描指定包] C --> D[识别@Component等注解] D --> E[创建BeanDefinition] E --> F[BeanFactory注册] F --> G[依赖注入] 2. 依赖注入注解 注解 作用 参数 示例 @Autowired 自动装配 required:是否必须 @Autowired private UserDao userDao; @Qualifier 指定Bean名称 value:Bean名称 @Qualifier("mysqlUserDao") @Resource JSR-250注入 name:指定Bean @Resource(name="userService") @Value 注入属性 value:属性值/表达式 @Value("${db.url}") @Primary 首选Bean 无 @Primary @Service 实现原理:

Read more →

Java开发经验大致

Java开发经验总结IJava经验小结 以下是Java开发编程经验的系统化总结,涵盖核心实践、高频踩坑点及进阶策略,适用于求职简历、晋升答辩或经验沉淀: 🔧 一、硬核技术实践 高并发场景 线程池调优:通过ThreadPoolExecutor自定义参数(核心/最大线程数、队列类型),避免Executors默认创建的OOM风险 并发工具应用: // 代替synchronized提升吞吐量 ReentrantLock lock = new ReentrantLock(true); // 公平锁减少线程饥饿 CountDownLatch latch = new CountDownLatch(3); // 多子任务并行聚合 规避死锁:用jstack分析线程栈,遵循锁顺序化或尝试Lock.tryLock() JVM性能攻坚

Read more →

August 8, 2025

函数式编程

函数式编程详解:概念、原理与实践什么是函数式编程? 函数式编程(Functional Programming,FP)是一种编程范式,它将计算视为数学函数的求值,并避免使用程序状态和可变数据。与命令式编程(如面向对象编程)不同,函数式编程强调函数的应用而非指令的执行。 核心概念与原理 1. 纯函数 (Pure Functions) // 纯函数示例 function add(a, b) { return a + b; } // 非纯函数示例(有副作用) let total = 0; function addToTotal(x) { total += x; // 修改了外部状态 return total; } 特性:

Read more →

August 8, 2025

编程范式

编程范式详解:从概念到实践编程范式(Programming Paradigm)是编程的基本风格和方法论,它定义了程序员思考问题和构建解决方案的方式。不同的范式提供了不同的抽象模型和代码组织方式,如同不同的"世界观"会影响我们解决问题的方法。 主要编程范式分类 graph TD A[编程范式] --> B[命令式范式] A --> C[声明式范式] B --> D[过程式编程] B --> E[面向对象编程] C --> F[函数式编程] C --> G[逻辑式编程] C --> H[响应式编程] 1. 命令式范式 (Imperative Programming) 核心思想:通过明确的指令序列告诉计算机如何完成任务(“如何做”) 1.1 过程式编程 (Procedural Programming) # 计算员工工资的示例 def calculate_salary(hours, rate): base_pay = hours * rate if hours > 40: overtime = (hours - 40) * rate * 0.5 base_pay += overtime tax = base_pay * 0.2 return base_pay - tax # 主程序流程 hours_worked = 45 hourly_rate = 20 net_pay = calculate_salary(hours_worked, hourly_rate) print(f"Net pay: ${net_pay:.2f}") 特点:

Read more →

August 8, 2025